bgp: fix bug of not taking care of withdrawn label

Reported-by: Toshiki Tsuboi <t.tsubo2000@gmail.com>
Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
This commit is contained in:
ISHIDA Wataru 2015-07-06 15:25:47 +09:00 committed by FUJITA Tomonori
parent 625aefffa2
commit fba7213421
1 changed files with 9 additions and 0 deletions

View File

@ -772,6 +772,13 @@ class _BinAddrPrefix(_AddrPrefix):
class _LabelledAddrPrefix(_AddrPrefix):
_LABEL_PACK_STR = '!3B'
# RFC3107
# 3. Carrying Label Mapping Information
# The label information carried (as part of NLRI) in the Withdrawn
# Routes field should be set to 0x800000. (Of course, terminating the
# BGP session also withdraws all the previously advertised routes.)
#
_WITHDRAW_LABEL = 0x800000
def __init__(self, length, addr, labels=[], **kwargs):
assert isinstance(labels, list)
@ -843,6 +850,8 @@ class _LabelledAddrPrefix(_AddrPrefix):
while True:
(label, rest) = cls._label_from_bin(rest)
if label == cls._WITHDRAW_LABEL:
break
labels.append(label >> 4)
if label & 1: # bottom of stack
break