mirror of
https://github.com/faucetsdn/ryu.git
synced 2026-05-08 22:06:10 +02:00
bgp: add code to handle RD 0:0 at the head of nexthop network address in MP_REACH_NLRI path attribute
The second is patch to add or skip RD 0:0 label for the next_hop address in MP_REACH_NLRI attribute. According to RFC, next_hop address seems to be required to contain RD of 0 when advertise VPN prefix. This is defined in RFC 4659(3.2.1.1. BGP Speaker Requesting IPv6 Transport) for VPN-IPv6 and in RFC 4364(4.3.2. Route Distribution Among PEs by BGP) for VPN-IPv4. Signed-off-by: Hiroshi Yokoi <yokoi.hiroshi@po.ntts.co.jp> Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
This commit is contained in:
parent
cc3c00b663
commit
7acda14a5d
@ -1771,6 +1771,7 @@ class BGPPathAttributeMpReachNLRI(_PathAttribute):
|
||||
_VALUE_PACK_STR = '!HBB' # afi, safi, next hop len
|
||||
_ATTR_FLAGS = BGP_ATTR_FLAG_OPTIONAL
|
||||
_class_prefixes = ['_BinAddrPrefix']
|
||||
_rd_length = 8
|
||||
|
||||
def __init__(self, afi, safi, next_hop, nlri,
|
||||
next_hop_len=0, reserved='\0',
|
||||
@ -1806,8 +1807,16 @@ class BGPPathAttributeMpReachNLRI(_PathAttribute):
|
||||
while binnlri:
|
||||
n, binnlri = addr_cls.parser(binnlri)
|
||||
nlri.append(n)
|
||||
if RouteFamily(afi, safi) in (RF_IPv6_UC, RF_IPv6_VPN):
|
||||
|
||||
rf = RouteFamily(afi, safi)
|
||||
if rf == RF_IPv6_UC:
|
||||
next_hop = addrconv.ipv6.bin_to_text(next_hop_bin)
|
||||
elif rf == RF_IPv6_VPN:
|
||||
next_hop = addrconv.ipv6.bin_to_text(next_hop_bin[cls._rd_length:])
|
||||
next_hop_len -= cls._rd_length
|
||||
elif rf == RF_IPv4_VPN:
|
||||
next_hop = addrconv.ipv4.bin_to_text(next_hop_bin[cls._rd_length:])
|
||||
next_hop_len -= cls._rd_length
|
||||
else:
|
||||
next_hop = addrconv.ipv4.bin_to_text(next_hop_bin)
|
||||
return {
|
||||
@ -1822,12 +1831,22 @@ class BGPPathAttributeMpReachNLRI(_PathAttribute):
|
||||
def serialize_value(self):
|
||||
# fixup
|
||||
self.next_hop_len = len(self._next_hop_bin)
|
||||
|
||||
if RouteFamily(self.afi, self.safi) in (RF_IPv4_VPN, RF_IPv6_VPN):
|
||||
empty_label_stack = '\x00' * self._rd_length
|
||||
next_hop_len = len(self._next_hop_bin) + len(empty_label_stack)
|
||||
next_hop_bin = empty_label_stack
|
||||
next_hop_bin += self._next_hop_bin
|
||||
else:
|
||||
next_hop_len = self.next_hop_len
|
||||
next_hop_bin = self._next_hop_bin
|
||||
|
||||
self.reserved = '\0'
|
||||
|
||||
buf = bytearray()
|
||||
msg_pack_into(self._VALUE_PACK_STR, buf, 0, self.afi,
|
||||
self.safi, self.next_hop_len)
|
||||
buf += self._next_hop_bin
|
||||
self.safi, next_hop_len)
|
||||
buf += next_hop_bin
|
||||
buf += self.reserved
|
||||
binnlri = bytearray()
|
||||
for n in self.nlri:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user