From: Donald Sharp Date: Fri, 20 Sep 2019 10:41:02 +0000 (-0400) Subject: bgpd: Invalid NH's should send an apropriate reason code X-Git-Tag: frr-7.2~16^2 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=refs%2Fpull%2F5027%2Fhead;p=mirror%2Ffrr.git bgpd: Invalid NH's should send an apropriate reason code RFC 4271 sec 6.3 p33, In the case of a BGP_NEXTHOP attribute with an incorrect value, FRR is supposed to send a notification and include 'Corresponding type, length and value of the NEXT_HOP attribute in the notification data. Fixes: #4997 Signed-off-by: Nikos Signed-off-by: Donald Sharp --- diff --git a/bgpd/bgp_attr.c b/bgpd/bgp_attr.c index ab9dc3092a..47ecfce41e 100644 --- a/bgpd/bgp_attr.c +++ b/bgpd/bgp_attr.c @@ -1305,14 +1305,20 @@ bgp_attr_nexthop_valid(struct peer *peer, struct attr *attr) if ((IPV4_NET0(nexthop_h) || IPV4_NET127(nexthop_h) || IPV4_CLASS_DE(nexthop_h)) && !BGP_DEBUG(allow_martians, ALLOW_MARTIANS)) { + uint8_t data[7]; /* type(2) + length(1) + nhop(4) */ char buf[INET_ADDRSTRLEN]; inet_ntop(AF_INET, &attr->nexthop.s_addr, buf, INET_ADDRSTRLEN); flog_err(EC_BGP_ATTR_MARTIAN_NH, "Martian nexthop %s", buf); - bgp_notify_send(peer, BGP_NOTIFY_UPDATE_ERR, - BGP_NOTIFY_UPDATE_INVAL_NEXT_HOP); + data[0] = BGP_ATTR_FLAG_TRANS; + data[1] = BGP_ATTR_NEXT_HOP; + data[2] = BGP_ATTR_NHLEN_IPV4; + memcpy(&data[3], &attr->nexthop.s_addr, BGP_ATTR_NHLEN_IPV4); + bgp_notify_send_with_data(peer, BGP_NOTIFY_UPDATE_ERR, + BGP_NOTIFY_UPDATE_INVAL_NEXT_HOP, + data, 7); return BGP_ATTR_PARSE_ERROR; }