diff options
author | Ondrej Zajicek <santiago@crfreenet.org> | 2014-10-14 17:23:34 +0200 |
---|---|---|
committer | Ondrej Zajicek <santiago@crfreenet.org> | 2014-10-14 17:23:34 +0200 |
commit | 78342404ff573e85e396f0611014b90cea9b4c0a (patch) | |
tree | 39fd70db506dc05d83528b7afab258b07b8ac482 /proto | |
parent | 178a197afb77770d8a90765e39065679936a45d1 (diff) | |
parent | cfdea7b85f6c520cc5a62eb907d2190db14c9900 (diff) |
Merge remote-tracking branch 'origin/master' into soft-int
Diffstat (limited to 'proto')
-rw-r--r-- | proto/bfd/bfd.c | 4 | ||||
-rw-r--r-- | proto/bgp/bgp.c | 4 | ||||
-rw-r--r-- | proto/bgp/bgp.h | 1 | ||||
-rw-r--r-- | proto/bgp/config.Y | 5 | ||||
-rw-r--r-- | proto/bgp/packets.c | 3 | ||||
-rw-r--r-- | proto/radv/config.Y | 11 | ||||
-rw-r--r-- | proto/radv/packets.c | 14 | ||||
-rw-r--r-- | proto/radv/radv.c | 1 | ||||
-rw-r--r-- | proto/radv/radv.h | 6 |
9 files changed, 36 insertions, 13 deletions
diff --git a/proto/bfd/bfd.c b/proto/bfd/bfd.c index 7bbe8c21..23e04e40 100644 --- a/proto/bfd/bfd.c +++ b/proto/bfd/bfd.c @@ -1062,7 +1062,7 @@ bfd_copy_config(struct proto_config *dest, struct proto_config *src) // struct bfd_config *s = (struct bfd_config *) src; /* We clean up patt_list and neigh_list, neighbors and ifaces are non-sharable */ - init_list(&d->patt_list); + init_list(&d->patt_list); init_list(&d->neigh_list); } @@ -1071,7 +1071,7 @@ bfd_show_sessions(struct proto *P) { byte tbuf[TM_DATETIME_BUFFER_SIZE]; struct bfd_proto *p = (struct bfd_proto *) P; - uint state, diag; + uint state, diag UNUSED; u32 tx_int, timeout; const char *ifname; diff --git a/proto/bgp/bgp.c b/proto/bgp/bgp.c index b6239971..e2339112 100644 --- a/proto/bgp/bgp.c +++ b/proto/bgp/bgp.c @@ -680,8 +680,8 @@ bgp_connect(struct bgp_proto *p) /* Enter Connect state and start establishing c s->type = SK_TCP_ACTIVE; s->saddr = p->source_addr; s->daddr = p->cf->remote_ip; + s->dport = p->cf->remote_port; s->iface = p->neigh ? p->neigh->iface : NULL; - s->dport = BGP_PORT; s->ttl = p->cf->ttl_security ? 255 : hops; s->rbsize = BGP_RX_BUFFER_SIZE; s->tbsize = BGP_TX_BUFFER_SIZE; @@ -1016,9 +1016,9 @@ bgp_start(struct proto *P) lock = p->lock = olock_new(P->pool); lock->addr = p->cf->remote_ip; + lock->port = p->cf->remote_port; lock->iface = p->cf->iface; lock->type = OBJLOCK_TCP; - lock->port = BGP_PORT; lock->hook = bgp_start_locked; lock->data = p; olock_acquire(lock); diff --git a/proto/bgp/bgp.h b/proto/bgp/bgp.h index da0114c2..0fd3a73c 100644 --- a/proto/bgp/bgp.h +++ b/proto/bgp/bgp.h @@ -23,6 +23,7 @@ struct bgp_config { ip_addr remote_ip; ip_addr source_addr; /* Source address to use */ struct iface *iface; /* Interface for link-local addresses */ + u16 remote_port; /* Neighbor destination port */ int multihop; /* Number of hops if multihop */ int ttl_security; /* Enable TTL security [RFC5082] */ int next_hop_self; /* Always set next hop to local IP address */ diff --git a/proto/bgp/config.Y b/proto/bgp/config.Y index 4d085d42..8e0b2412 100644 --- a/proto/bgp/config.Y +++ b/proto/bgp/config.Y @@ -60,7 +60,7 @@ bgp_proto: | bgp_proto proto_item ';' | bgp_proto LOCAL AS expr ';' { BGP_CFG->local_as = $4; } | bgp_proto LOCAL ipa AS expr ';' { BGP_CFG->source_addr = $3; BGP_CFG->local_as = $5; } - | bgp_proto NEIGHBOR ipa ipa_scope AS expr ';' { + | bgp_proto NEIGHBOR ipa ipa_scope ipa_port AS expr ';' { if (ipa_nonzero(BGP_CFG->remote_ip)) cf_error("Only one neighbor per BGP instance is allowed"); if (!ipa_has_link_scope($3) != !$4) @@ -68,7 +68,8 @@ bgp_proto: BGP_CFG->remote_ip = $3; BGP_CFG->iface = $4; - BGP_CFG->remote_as = $6; + BGP_CFG->remote_port = ($5 > 0) ? $5 : BGP_PORT; + BGP_CFG->remote_as = $7; } | bgp_proto RR CLUSTER ID idval ';' { BGP_CFG->rr_cluster_id = $5; } | bgp_proto RR CLIENT ';' { BGP_CFG->rr_client = 1; } diff --git a/proto/bgp/packets.c b/proto/bgp/packets.c index 4464523d..0b9de8c1 100644 --- a/proto/bgp/packets.c +++ b/proto/bgp/packets.c @@ -22,7 +22,8 @@ #include "bgp.h" -static struct rate_limit rl_rcv_update, rl_snd_update; +static struct tbf rl_rcv_update = TBF_DEFAULT_LOG_LIMITS; +static struct tbf rl_snd_update = TBF_DEFAULT_LOG_LIMITS; /* Table for state -> RFC 6608 FSM error subcodes */ static byte fsm_err_subcode[BS_MAX] = { diff --git a/proto/radv/config.Y b/proto/radv/config.Y index 88a9e298..a26ea88e 100644 --- a/proto/radv/config.Y +++ b/proto/radv/config.Y @@ -30,9 +30,9 @@ CF_KEYWORDS(RADV, PREFIX, INTERFACE, MIN, MAX, RA, DELAY, INTERVAL, MANAGED, OTHER, CONFIG, LINK, MTU, REACHABLE, TIME, RETRANS, TIMER, CURRENT, HOP, LIMIT, DEFAULT, VALID, PREFERRED, MULT, LIFETIME, SKIP, ONLINK, AUTONOMOUS, RDNSS, DNSSL, NS, DOMAIN, - LOCAL, TRIGGER, SENSITIVE) + LOCAL, TRIGGER, SENSITIVE, PREFERENCE, LOW, MEDIUM, HIGH) -%type<i> radv_mult radv_sensitive +%type<i> radv_mult radv_sensitive radv_preference CF_GRAMMAR @@ -84,6 +84,7 @@ radv_iface_start: RADV_IFACE->current_hop_limit = DEFAULT_CURRENT_HOP_LIMIT; RADV_IFACE->default_lifetime = -1; RADV_IFACE->default_lifetime_sensitive = 1; + RADV_IFACE->default_preference = RA_PREF_MEDIUM; }; radv_iface_item: @@ -101,6 +102,7 @@ radv_iface_item: if (($3 < 0) || ($3 > 9000)) cf_error("Default lifetime must be in range 0-9000"); if ($4 != -1) RADV_IFACE->default_lifetime_sensitive = $4; } + | DEFAULT PREFERENCE radv_preference { RADV_IFACE->default_preference = $3; } | PREFIX radv_prefix { add_tail(&RADV_IFACE->pref_list, NODE this_radv_prefix); } | RDNSS { init_list(&radv_dns_list); } radv_rdnss { add_tail_list(&RADV_IFACE->rdnss_list, &radv_dns_list); } | DNSSL { init_list(&radv_dns_list); } radv_dnssl { add_tail_list(&RADV_IFACE->dnssl_list, &radv_dns_list); } @@ -108,6 +110,11 @@ radv_iface_item: | DNSSL LOCAL bool { RADV_IFACE->dnssl_local = $3; } ; +radv_preference: + LOW { $$ = RA_PREF_LOW; } + | MEDIUM { $$ = RA_PREF_MEDIUM; } + | HIGH { $$ = RA_PREF_HIGH; } + radv_iface_finish: { struct radv_iface_config *ic = RADV_IFACE; diff --git a/proto/radv/packets.c b/proto/radv/packets.c index 1d7e04f4..ef869722 100644 --- a/proto/radv/packets.c +++ b/proto/radv/packets.c @@ -251,10 +251,11 @@ radv_prepare_ra(struct radv_iface *ifa) pkt->code = 0; pkt->checksum = 0; pkt->current_hop_limit = ic->current_hop_limit; - pkt->flags = (ic->managed ? OPT_RA_MANAGED : 0) | - (ic->other_config ? OPT_RA_OTHER_CFG : 0); pkt->router_lifetime = (ra->active || !ic->default_lifetime_sensitive) ? htons(ic->default_lifetime) : 0; + pkt->flags = (ic->managed ? OPT_RA_MANAGED : 0) | + (ic->other_config ? OPT_RA_OTHER_CFG : 0) | + (pkt->router_lifetime ? ic->default_preference : 0); pkt->reachable_time = htonl(ic->reachable_time); pkt->retrans_timer = htonl(ic->retrans_timer); buf += sizeof(*pkt); @@ -330,10 +331,15 @@ radv_send_ra(struct radv_iface *ifa, int shutdown) if (shutdown) { - /* Modify router lifetime to 0, it is not restored because - we suppose that the iface will be removed */ + /* + * Modify router lifetime to 0, it is not restored because we suppose that + * the iface will be removed. The preference value also has to be zeroed. + * (RFC 4191 2.2: If router lifetime is 0, the preference value must be 0.) + */ + struct radv_ra_packet *pkt = (void *) ifa->sk->tbuf; pkt->router_lifetime = 0; + pkt->flags &= ~RA_PREF_MASK; } RADV_TRACE(D_PACKETS, "Sending RA via %s", ifa->iface->name); diff --git a/proto/radv/radv.c b/proto/radv/radv.c index 90408536..6be7cd84 100644 --- a/proto/radv/radv.c +++ b/proto/radv/radv.c @@ -40,6 +40,7 @@ * Supported standards: * - RFC 4861 - main RA standard * - RFC 6106 - DNS extensions (RDDNS, DNSSL) + * - RFC 4191 (partial) - Default Router Preference */ static void diff --git a/proto/radv/radv.h b/proto/radv/radv.h index f80e4530..bb80d65f 100644 --- a/proto/radv/radv.h +++ b/proto/radv/radv.h @@ -80,6 +80,7 @@ struct radv_iface_config u32 current_hop_limit; u32 default_lifetime; u8 default_lifetime_sensitive; /* Whether default_lifetime depends on trigger */ + u8 default_preference; /* Default Router Preference (RFC 4191) */ }; struct radv_prefix_config @@ -144,6 +145,11 @@ struct radv_iface #define RA_EV_CHANGE 2 /* Change of options or prefixes */ #define RA_EV_RS 3 /* Received RS */ +/* Default Router Preferences (RFC 4191) */ +#define RA_PREF_LOW 0x18 +#define RA_PREF_MEDIUM 0x00 +#define RA_PREF_HIGH 0x08 +#define RA_PREF_MASK 0x18 #ifdef LOCAL_DEBUG |