--- embedaddon/bird/proto/radv/radv.h 2017/08/22 12:33:54 1.1.1.1 +++ embedaddon/bird/proto/radv/radv.h 2021/03/17 19:50:23 1.1.1.2 @@ -53,6 +53,8 @@ struct radv_config ip_addr trigger_prefix; /* Prefix of a trigger route, if defined */ u8 trigger_pxlen; /* Pxlen of a trigger route, if defined */ u8 trigger_valid; /* Whether a trigger route is defined */ + u8 propagate_routes; /* Do we propagate more specific routes (RFC 4191)? */ + u32 max_linger_time; /* Maximum of interface route_linger_time */ }; struct radv_iface_config @@ -62,22 +64,28 @@ struct radv_iface_config list rdnss_list; /* Local list of RDNSS configs (struct radv_rdnss_config) */ list dnssl_list; /* Local list of DNSSL configs (struct radv_dnssl_config) */ - u32 min_ra_int; /* Standard options from RFC 4261 */ + u32 min_ra_int; /* Standard options from RFC 4861 */ u32 max_ra_int; u32 min_delay; + u32 prefix_linger_time; /* How long we advertise dead prefixes with lifetime 0 */ + u32 route_linger_time; /* How long we advertise dead routes with lifetime 0 */ + u8 rdnss_local; /* Global list is not used for RDNSS */ u8 dnssl_local; /* Global list is not used for DNSSL */ - u8 managed; /* Standard options from RFC 4261 */ + u8 managed; /* Standard options from RFC 4861 */ u8 other_config; u32 link_mtu; u32 reachable_time; u32 retrans_timer; u32 current_hop_limit; u32 default_lifetime; + u32 route_lifetime; /* Lifetime for the RFC 4191 routes */ u8 default_lifetime_sensitive; /* Whether default_lifetime depends on trigger */ + u8 route_lifetime_sensitive; /* Whether route_lifetime depends on trigger */ u8 default_preference; /* Default Router Preference (RFC 4191) */ + u8 route_preference; /* Specific Route Preference (RFC 4191) */ }; struct radv_prefix_config @@ -87,7 +95,7 @@ struct radv_prefix_config uint pxlen; u8 skip; /* Do not include this prefix to RA */ - u8 onlink; /* Standard options from RFC 4261 */ + u8 onlink; /* Standard options from RFC 4861 */ u8 autonomous; u32 valid_lifetime; u32 preferred_lifetime; @@ -113,21 +121,58 @@ struct radv_dnssl_config char *domain; /* Domain for DNS search list, in processed form */ }; +/* + * One more specific route as per RFC 4191. + * + * Note that it does *not* contain the next hop field. The next hop is always + * the router sending the advertisment and the more specific route only allows + * overriding the preference of the route. + */ +struct radv_route +{ + struct fib_node n; + u32 lifetime; /* Lifetime from an attribute */ + u8 lifetime_set; /* Whether lifetime is defined */ + u8 preference; /* Preference of the route, RA_PREF_* */ + u8 preference_set; /* Whether preference is defined */ + u8 valid; /* Whethe route is valid or withdrawn */ + bird_clock_t changed; /* Last time when the route changed */ +}; -struct proto_radv +struct radv_proto { struct proto p; list iface_list; /* List of active ifaces */ + u8 valid; /* Router is valid for forwarding, used for shutdown */ u8 active; /* Whether radv is active w.r.t. triggers */ + u8 fib_up; /* FIB table (routes) is initialized */ + struct fib routes; /* FIB table of specific routes (struct radv_route) */ + bird_clock_t prune_time; /* Next time of route table pruning */ }; +struct radv_prefix /* One prefix we advertise */ +{ + node n; + ip_addr prefix; + u8 len; + u8 valid; /* Is the prefix valid? If not, we advertise it + with 0 lifetime, so clients stop using it */ + u8 mark; /* A temporary mark for processing */ + bird_clock_t changed; /* Last time when the prefix changed */ + struct radv_prefix_config *cf; /* The config tied to this prefix */ +}; + struct radv_iface { node n; - struct proto_radv *ra; + struct radv_proto *ra; struct radv_iface_config *cf; /* Related config, must be updated in reconfigure */ struct iface *iface; struct ifa *addr; /* Link-local address of iface */ + struct pool *pool; /* A pool for interface-specific things */ + list prefixes; /* The prefixes we advertise (struct radv_prefix) */ + bird_clock_t prune_time; /* Next time of prefix list pruning */ + bird_clock_t valid_time; /* Cached packet is valid until first linger timeout */ timer *timer; struct object_lock *lock; @@ -135,7 +180,7 @@ struct radv_iface bird_clock_t last; /* Time of last sending of RA */ u16 plen; /* Length of prepared RA in tbuf, or 0 if not valid */ - byte initial; /* List of active ifaces */ + byte initial; /* How many RAs are still to be sent as initial */ }; #define RA_EV_INIT 1 /* Switch to initial mode */ @@ -148,14 +193,17 @@ struct radv_iface #define RA_PREF_HIGH 0x08 #define RA_PREF_MASK 0x18 +/* Attributes */ +#define EA_RA_PREFERENCE EA_CODE(EAP_RADV, 0) +#define EA_RA_LIFETIME EA_CODE(EAP_RADV, 1) #ifdef LOCAL_DEBUG #define RADV_FORCE_DEBUG 1 #else #define RADV_FORCE_DEBUG 0 #endif -#define RADV_TRACE(flags, msg, args...) do { if ((ra->p.debug & flags) || RADV_FORCE_DEBUG) \ - log(L_TRACE "%s: " msg, ra->p.name , ## args ); } while(0) +#define RADV_TRACE(flags, msg, args...) do { if ((p->p.debug & flags) || RADV_FORCE_DEBUG) \ + log(L_TRACE "%s: " msg, p->p.name , ## args ); } while(0) /* radv.c */ @@ -163,7 +211,7 @@ void radv_iface_notify(struct radv_iface *ifa, int eve /* packets.c */ int radv_process_domain(struct radv_dnssl_config *cf); -void radv_send_ra(struct radv_iface *ifa, int shutdown); +void radv_send_ra(struct radv_iface *ifa); int radv_sk_open(struct radv_iface *ifa);