summaryrefslogtreecommitdiffstats
path: root/bgpd/bgp_route.c
diff options
context:
space:
mode:
authorPaul Jakma <paul.jakma@hpe.com>2016-02-04 13:27:04 +0000
committerPaul Jakma <paul.jakma@hpe.com>2016-03-08 17:53:21 +0000
commit518a4b7eadcba567f01061e6659d8179380efcdf (patch)
tree0bc751d4e0024954e1bf3bf5a7e0ce84b219ba1f /bgpd/bgp_route.c
parent18ab08b71e6b29e67b36df5e2261569d381b1708 (diff)
downloadquagga-518a4b7eadcba567f01061e6659d8179380efcdf.tar.bz2
quagga-518a4b7eadcba567f01061e6659d8179380efcdf.tar.xz
bgpd: Regularise bgp_update_receive, add missing notifies and checks
* bgp_packet.c: (bgp_update_receive) Lots of repeated code, doing same thing for each AFI/SAFI. Except when it doesn't, e.g. the IPv4/VPN case was missing the EoR bgp_clear_stale_route call - the only action really needed for EoR. Make this function a lot more regular, using common, AFI/SAFI independent blocks so far as possible. Replace the 4 separate bgp_nlris with an array, indexed by an enum. The distinct blocks that handle calling bgp_nlri_parse for each different AFI/SAFI can now be replaced with a loop. Transmogrify the nlri SAFI from the SAFI_MPLS_LABELED_VPN code-point used on the wire, to the SAFI_MPLS_VPN safi_t enum we use internally as early as possible. The existing code was not necessarily sending a NOTIFY for NLRI parsing errors, if they arose via bgp_nlri_sanity_check. Send the correct NOTIFY - INVAL_NETWORK for the classic NLRIs and OPT_ATTR_ERR for the MP ones. EoR can now be handled in one block. The existing code seemed broken for EoR recognition in a number of ways: 1. A v4/unicast EoR should be an empty UPDATE. However, it seemed to be treating an UPDATE with attributes, inc. MP REACH/UNREACH, but no classic NLRIs, as a v4/uni EoR. 2. For other AFI/SAFIs, it was treating UPDATEs with no classic withraw and with a zero-length MP withdraw as EoRs. However, that would mean an UPDATE packet _with_ update NLRIs and a 0-len MP withdraw could be classed as an EoR. This seems to be loose coding leading to ambiguous protocol situations and likely incorrect behaviour, rather than simply being liberal. Be more strict about checking that an UPDATE really is an EoR and definitely is not trying to update any NLRIs. This same loose EoR parsing was noted by Chris Hall previously on list. (bgp_nlri_parse) Front end NLRI parse function, to fan-out to the correct parser for the AFI/SAFI. * bgp_route.c: (bgp_nlri_sanity_check) We try convert NLRI safi to internal code-point ASAP, adjust switch for that. Leave the wire code point in for defensive coding. (bgp_nlri_parse) rename to bgp_nlri_parse_ip. * tests/bgp_mp_attr_test.c: Can just use bgp_nlri_parse frontend.
Diffstat (limited to 'bgpd/bgp_route.c')
-rw-r--r--bgpd/bgp_route.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c
index c1e5e59b..b581fd99 100644
--- a/bgpd/bgp_route.c
+++ b/bgpd/bgp_route.c
@@ -3226,7 +3226,8 @@ bgp_reset (void)
/* Parse NLRI stream. Withdraw NLRI is recognized by NULL attr
value. */
int
-bgp_nlri_parse (struct peer *peer, struct attr *attr, struct bgp_nlri *packet)
+bgp_nlri_parse_ip (struct peer *peer, struct attr *attr,
+ struct bgp_nlri *packet)
{
u_char *pnt;
u_char *lim;
@@ -3401,6 +3402,7 @@ bgp_nlri_sanity_check (struct peer *peer, struct bgp_nlri *nlri)
switch (nlri->safi)
{
case SAFI_MPLS_LABELED_VPN:
+ case SAFI_MPLS_VPN:
return bgp_nlri_sanity_check_vpn (peer, nlri);
case SAFI_UNICAST:
case SAFI_MULTICAST: