]> git.proxmox.com Git - mirror_frr.git/commitdiff
bgpd: factorise ipv6 vpn nexthop encoding
authorPhilippe Guibert <philippe.guibert@6wind.com>
Mon, 13 Feb 2023 11:17:28 +0000 (12:17 +0100)
committerPhilippe Guibert <philippe.guibert@6wind.com>
Wed, 15 Feb 2023 16:02:15 +0000 (17:02 +0100)
Because mp_nexthop_len attribute value stands for the length
to encode in the stream, simplify the way the nexthop is
forged.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
bgpd/bgp_attr.c

index 572475f06856a5e4258c64506860ae849c9268b0..fec897f2f18da8a08c021259574390460a1ae5bd 100644 (file)
@@ -3983,23 +3983,21 @@ size_t bgp_packet_mpattr_start(struct stream *s, struct peer *peer, afi_t afi,
                        }
                } break;
                case SAFI_MPLS_VPN: {
+                       if (attr->mp_nexthop_len ==
+                           BGP_ATTR_NHLEN_VPNV6_GLOBAL_AND_LL)
+                               stream_putc(s, attr->mp_nexthop_len);
+                       else
+                               stream_putc(s, BGP_ATTR_NHLEN_VPNV6_GLOBAL);
+                       stream_putl(s, 0); /* RD = 0, per RFC */
+                       stream_putl(s, 0);
+                       stream_put(s, &attr->mp_nexthop_global,
+                                  IPV6_MAX_BYTELEN);
                        if (attr->mp_nexthop_len ==
                            BGP_ATTR_NHLEN_VPNV6_GLOBAL_AND_LL) {
-                               stream_putc(s, 48);
-                               stream_putl(s, 0); /* RD = 0, per RFC */
-                               stream_putl(s, 0);
-                               stream_put(s, &attr->mp_nexthop_global,
-                                          IPV6_MAX_BYTELEN);
                                stream_putl(s, 0); /* RD = 0, per RFC */
                                stream_putl(s, 0);
                                stream_put(s, &attr->mp_nexthop_local,
                                           IPV6_MAX_BYTELEN);
-                       } else {
-                               stream_putc(s, 24);
-                               stream_putl(s, 0); /* RD = 0, per RFC */
-                               stream_putl(s, 0);
-                               stream_put(s, &attr->mp_nexthop_global,
-                                          IPV6_MAX_BYTELEN);
                        }
                } break;
                case SAFI_ENCAP: