summaryrefslogtreecommitdiff
path: root/proto/rip
diff options
context:
space:
mode:
authorOndrej Zajicek (work) <santiago@crfreenet.org>2015-12-21 03:27:41 +0100
committerOndrej Zajicek (work) <santiago@crfreenet.org>2015-12-21 03:33:18 +0100
commit23c212e7f1e80a3c6b88b49918972bc28375bd51 (patch)
treee2e162e5f3454ba1213435acf5980bbc4e4ed5d3 /proto/rip
parente92a4b855f668e8ac685ad79c288ff182ebd110b (diff)
Follow-up work on integration
Diffstat (limited to 'proto/rip')
-rw-r--r--proto/rip/config.Y13
-rw-r--r--proto/rip/packets.c3
-rw-r--r--proto/rip/rip.c6
-rw-r--r--proto/rip/rip.h12
4 files changed, 17 insertions, 17 deletions
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)