Fix nlri parsing of L3VPN prefixes in withdrawals.
authorclaudio <claudio@openbsd.org>
Wed, 9 Nov 2022 14:23:53 +0000 (14:23 +0000)
committerclaudio <claudio@openbsd.org>
Wed, 9 Nov 2022 14:23:53 +0000 (14:23 +0000)
L3VPN NLRI have different encoding for updates and withdraws. The withdraw
carries one dummy MPLS label that needs to be skipped. The code doing that
did adjust the lenght but did not skip the the label in the buffer and so
the parsed prefix was off by 3 bytes.
OK tb@

usr.sbin/bgpd/util.c

index 83ca442..1922f05 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: util.c,v 1.72 2022/11/07 11:33:24 mbuhl Exp $ */
+/*     $OpenBSD: util.c,v 1.73 2022/11/09 14:23:53 claudio Exp $ */
 
 /*
  * Copyright (c) 2006 Claudio Jeker <claudio@openbsd.org>
@@ -131,7 +131,9 @@ log_rd(uint64_t rd)
                snprintf(buf, sizeof(buf), "rd %s:%hu", inet_ntoa(addr), u16);
                break;
        default:
-               return ("rd ?");
+               snprintf(buf, sizeof(buf), "rd #%016llx",
+                   (unsigned long long)rd);
+               break;
        }
        return (buf);
 }
@@ -596,6 +598,7 @@ nlri_get_vpn4(u_char *p, uint16_t len, struct bgpd_addr *prefix,
                        return (-1);
                if (withdraw) {
                        /* on withdraw ignore the labelstack all together */
+                       p += 3;
                        plen += 3;
                        pfxlen -= 3 * 8;
                        break;
@@ -659,6 +662,7 @@ nlri_get_vpn6(u_char *p, uint16_t len, struct bgpd_addr *prefix,
                        return (-1);
                if (withdraw) {
                        /* on withdraw ignore the labelstack all together */
+                       p += 3;
                        plen += 3;
                        pfxlen -= 3 * 8;
                        break;