bgpd: encap: add encap SAFI (RFC5512)
Adds RFC5512 and Encapsulation Attribute.
Signed-off-by: Lou Berger <lberger@labn.net>
diff --git a/bgpd/bgp_packet.c b/bgpd/bgp_packet.c
index 841eaab..1d18779 100644
--- a/bgpd/bgp_packet.c
+++ b/bgpd/bgp_packet.c
@@ -47,6 +47,7 @@
#include "bgpd/bgp_ecommunity.h"
#include "bgpd/bgp_network.h"
#include "bgpd/bgp_mplsvpn.h"
+#include "bgpd/bgp_encap.h"
#include "bgpd/bgp_advertise.h"
#include "bgpd/bgp_vty.h"
@@ -212,7 +213,9 @@
/* 5: Encode all the attributes, except MP_REACH_NLRI attr. */
total_attr_len = bgp_packet_attribute (NULL, peer, s,
adv->baa->attr,
- &rn->p, afi, safi,
+ ((afi == AFI_IP && safi == SAFI_UNICAST) ?
+ &rn->p : NULL),
+ afi, safi,
from, prd, tag);
}
@@ -1939,6 +1942,54 @@
peer->host);
}
}
+ if (peer->afc[AFI_IP][SAFI_ENCAP])
+ {
+ if (mp_update.length
+ && mp_update.afi == AFI_IP
+ && mp_update.safi == SAFI_ENCAP)
+ bgp_nlri_parse_encap (mp_update.afi, peer, &attr, &mp_update, 0);
+
+ if (mp_withdraw.length
+ && mp_withdraw.afi == AFI_IP
+ && mp_withdraw.safi == SAFI_ENCAP)
+ bgp_nlri_parse_encap (mp_withdraw.afi, peer, &attr, &mp_withdraw, 1);
+
+ if (! withdraw_len
+ && mp_withdraw.afi == AFI_IP
+ && mp_withdraw.safi == SAFI_MPLS_LABELED_VPN
+ && mp_withdraw.length == 0)
+ {
+ /* End-of-RIB received */
+
+ if (BGP_DEBUG (update, UPDATE_IN))
+ zlog (peer->log, LOG_DEBUG, "rcvd End-of-RIB for Encap Unicast from %s",
+ peer->host);
+ }
+ }
+ if (peer->afc[AFI_IP6][SAFI_ENCAP])
+ {
+ if (mp_update.length
+ && mp_update.afi == AFI_IP6
+ && mp_update.safi == SAFI_ENCAP)
+ bgp_nlri_parse_encap (mp_update.afi, peer, &attr, &mp_update, 0);
+
+ if (mp_withdraw.length
+ && mp_withdraw.afi == AFI_IP6
+ && mp_withdraw.safi == SAFI_ENCAP)
+ bgp_nlri_parse_encap (mp_withdraw.afi, peer, &attr, &mp_withdraw, 1);
+
+ if (! withdraw_len
+ && mp_withdraw.afi == AFI_IP6
+ && mp_withdraw.safi == SAFI_MPLS_LABELED_VPN
+ && mp_withdraw.length == 0)
+ {
+ /* End-of-RIB received */
+
+ if (BGP_DEBUG (update, UPDATE_IN))
+ zlog (peer->log, LOG_DEBUG, "rcvd End-of-RIB for Encap Unicast from %s",
+ peer->host);
+ }
+ }
/* Everything is done. We unintern temporary structures which
interned in bgp_attr_parse(). */