diff options
Diffstat (limited to 'proto')
-rw-r--r-- | proto/ospf/config.Y | 14 | ||||
-rw-r--r-- | proto/ospf/ospf.c | 3 | ||||
-rw-r--r-- | proto/ospf/ospf.h | 14 | ||||
-rw-r--r-- | proto/ospf/rt.c | 2 | ||||
-rw-r--r-- | proto/rip/config.Y | 13 | ||||
-rw-r--r-- | proto/rip/packets.c | 3 | ||||
-rw-r--r-- | proto/rip/rip.c | 6 | ||||
-rw-r--r-- | proto/rip/rip.h | 12 |
8 files changed, 32 insertions, 35 deletions
diff --git a/proto/ospf/config.Y b/proto/ospf/config.Y index e8fb7f2e..6d8fa755 100644 --- a/proto/ospf/config.Y +++ b/proto/ospf/config.Y @@ -130,21 +130,27 @@ CF_KEYWORDS(ELIGIBLE, POLL, NETWORKS, HIDDEN, VIRTUAL, CHECK, LINK, ONLY, BFD) CF_KEYWORDS(RX, BUFFER, LARGE, NORMAL, STUBNET, HIDDEN, SUMMARY, TAG, EXTERNAL) CF_KEYWORDS(WAIT, DELAY, LSADB, ECMP, LIMIT, WEIGHT, NSSA, TRANSLATOR, STABILITY) CF_KEYWORDS(GLOBAL, LSID, ROUTER, SELF, INSTANCE, REAL, NETMASK, TX, PRIORITY, LENGTH) -CF_KEYWORDS(SECONDARY, MERGE, LSA, SUPPRESSION) +CF_KEYWORDS(SECONDARY, MERGE, LSA, SUPPRESSION, OSPF2, OSPF3) %type <ld> lsadb_args -%type <i> nbma_eligible +%type <i> ospf_variant nbma_eligible CF_GRAMMAR CF_ADDTO(proto, ospf_proto '}' { ospf_proto_finish(); } ) -ospf_proto_start: proto_start OSPF { +ospf_variant: + OSPF { $$ = 1; } + | OSPF2 { $$ = 1; } + | OSPF3 { $$ = 0; } + ; + +ospf_proto_start: proto_start ospf_variant { this_proto = proto_config_new(&proto_ospf, $1); init_list(&OSPF_CFG->area_list); init_list(&OSPF_CFG->vlink_list); OSPF_CFG->tick = OSPF_DEFAULT_TICK; - OSPF_CFG->ospf2 = OSPF_IS_V2; + OSPF_CFG->ospf2 = $2; } ; diff --git a/proto/ospf/ospf.c b/proto/ospf/ospf.c index 983f76f1..8008e4d8 100644 --- a/proto/ospf/ospf.c +++ b/proto/ospf/ospf.c @@ -648,6 +648,9 @@ ospf_reconfigure(struct proto *P, struct proto_config *c) if (proto_get_router_id(c) != p->router_id) return 0; + if (p->ospf2 != new->ospf2) + return 0; + if (p->rfc1583 != new->rfc1583) return 0; diff --git a/proto/ospf/ospf.h b/proto/ospf/ospf.h index 3e96b511..f4f91de1 100644 --- a/proto/ospf/ospf.h +++ b/proto/ospf/ospf.h @@ -37,14 +37,6 @@ #endif -#ifdef IPV6 -#define OSPF_IS_V2 0 -#else -#define OSPF_IS_V2 1 -#endif - -// FIXME: MAX_PREFIX_LENGTH - #define OSPF_TRACE(flags, msg, args...) \ do { if ((p->p.debug & flags) || OSPF_FORCE_DEBUG) \ log(L_TRACE "%s: " msg, p->p.name , ## args ); } while(0) @@ -837,16 +829,12 @@ static inline void ospf_notify_net_lsa(struct ospf_iface *ifa) static inline void ospf_notify_link_lsa(struct ospf_iface *ifa) { ifa->update_link_lsa = 1; } - -#define ospf_is_v2(X) OSPF_IS_V2 -#define ospf_is_v3(X) (!OSPF_IS_V2) -/* static inline int ospf_is_v2(struct ospf_proto *p) { return p->ospf2; } static inline int ospf_is_v3(struct ospf_proto *p) { return ! p->ospf2; } -*/ + static inline int ospf_get_version(struct ospf_proto *p) { return ospf_is_v2(p) ? 2 : 3; } diff --git a/proto/ospf/rt.c b/proto/ospf/rt.c index 0adc3871..0031089c 100644 --- a/proto/ospf/rt.c +++ b/proto/ospf/rt.c @@ -1428,7 +1428,7 @@ loop: static void * ospf_fib_route(struct fib *f, ip_addr a) { - if (ospf_is_v2(p)) + if (f->addr_type == NET_IP4) return ospf_fib_route_ip4(f, ipa_to_ip4(a), IP4_MAX_PREFIX_LENGTH); else return ospf_fib_route_ip6(f, ipa_to_ip6(a), IP6_MAX_PREFIX_LENGTH); diff --git a/proto/rip/config.Y b/proto/rip/config.Y index 29ea7eb1..d81c42d7 100644 --- a/proto/rip/config.Y +++ b/proto/rip/config.Y @@ -32,24 +32,29 @@ rip_check_auth(void) CF_DECLS -CF_KEYWORDS(RIP, ECMP, LIMIT, WEIGHT, INFINITY, METRIC, UPDATE, TIMEOUT, +CF_KEYWORDS(RIP, RIPNG, ECMP, LIMIT, WEIGHT, INFINITY, METRIC, UPDATE, TIMEOUT, GARBAGE, PORT, ADDRESS, MODE, BROADCAST, MULTICAST, PASSIVE, VERSION, SPLIT, HORIZON, POISON, REVERSE, CHECK, ZERO, TIME, BFD, AUTHENTICATION, NONE, PLAINTEXT, CRYPTOGRAPHIC, MD5, TTL, SECURITY, RX, TX, BUFFER, LENGTH, PRIORITY, ONLY, LINK, RIP_METRIC, RIP_TAG) -%type <i> rip_auth +%type <i> rip_variant rip_auth CF_GRAMMAR CF_ADDTO(proto, rip_proto) -rip_proto_start: proto_start RIP +rip_variant: + RIP { $$ = 1; } + | RIPNG { $$ = 0; } + ; + +rip_proto_start: proto_start rip_variant { this_proto = proto_config_new(&proto_rip, $1); init_list(&RIP_CFG->patt_list); - RIP_CFG->rip2 = RIP_IS_V2; + RIP_CFG->rip2 = $2; RIP_CFG->infinity = RIP_DEFAULT_INFINITY; RIP_CFG->min_timeout_time = 60; diff --git a/proto/rip/packets.c b/proto/rip/packets.c index 85f0bea5..2e83a463 100644 --- a/proto/rip/packets.c +++ b/proto/rip/packets.c @@ -736,7 +736,8 @@ rip_open_socket(struct rip_iface *ifa) sk->tos = ifa->cf->tx_tos; sk->priority = ifa->cf->tx_priority; sk->ttl = ifa->cf->ttl_security ? 255 : 1; - sk->flags = SKF_LADDR_RX | ((ifa->cf->ttl_security == 1) ? SKF_TTL_RX : 0); + sk->flags = SKF_LADDR_RX | (rip_is_ng(p) ? SKF_V6ONLY : 0) | + ((ifa->cf->ttl_security == 1) ? SKF_TTL_RX : 0); /* sk->rbsize and sk->tbsize are handled in rip_iface_update_buffers() */ diff --git a/proto/rip/rip.c b/proto/rip/rip.c index d8c3b6a8..f90d7711 100644 --- a/proto/rip/rip.c +++ b/proto/rip/rip.c @@ -1097,11 +1097,12 @@ rip_start(struct proto *P) struct rip_config *cf = (void *) (P->cf); init_list(&p->iface_list); - fib_init(&p->rtable, P->pool, rip_is_v2(p) ? NET_IP4 : NET_IP6, + fib_init(&p->rtable, P->pool, cf->rip2 ? NET_IP4 : NET_IP6, sizeof(struct rip_entry), OFFSETOF(struct rip_entry, n), 0, NULL); p->rte_slab = sl_new(P->pool, sizeof(struct rip_rte)); p->timer = tm_new_set(P->pool, rip_timer, p, 0, 0); + p->rip2 = cf->rip2; p->ecmp = cf->ecmp; p->infinity = cf->infinity; p->triggered = 0; @@ -1121,6 +1122,9 @@ rip_reconfigure(struct proto *P, struct proto_config *c) struct rip_config *new = (void *) c; // struct rip_config *old = (void *) (P->cf); + if (new->rip2 != p->rip2) + return 0; + if (new->infinity != p->infinity) return 0; diff --git a/proto/rip/rip.h b/proto/rip/rip.h index 97c5ab3f..d1c9933c 100644 --- a/proto/rip/rip.h +++ b/proto/rip/rip.h @@ -27,12 +27,6 @@ #include "lib/timer.h" -#ifdef IPV6 -#define RIP_IS_V2 0 -#else -#define RIP_IS_V2 1 -#endif - #define RIP_V1 1 #define RIP_V2 2 @@ -98,6 +92,7 @@ struct rip_proto slab *rte_slab; /* Slab for internal routes (struct rip_rte) */ timer *timer; /* Main protocol timer */ + u8 rip2; /* RIPv2 (IPv4) or RIPng (IPv6) */ u8 ecmp; /* Maximum number of nexthops in ECMP route, or 0 */ u8 infinity; /* Maximum metric value, representing infinity */ u8 triggered; /* Logical AND of interface want_triggered values */ @@ -190,16 +185,11 @@ struct rip_rte #define EA_RIP_METRIC EA_CODE(EAP_RIP, 0) #define EA_RIP_TAG EA_CODE(EAP_RIP, 1) -#define rip_is_v2(X) RIP_IS_V2 -#define rip_is_ng(X) (!RIP_IS_V2) - -/* static inline int rip_is_v2(struct rip_proto *p) { return p->rip2; } static inline int rip_is_ng(struct rip_proto *p) { return ! p->rip2; } -*/ static inline void rip_reset_tx_session(struct rip_proto *p, struct rip_iface *ifa) |