]> git.proxmox.com Git - mirror_frr.git/blobdiff - bgpd/bgp_flowspec.c
Merge pull request #9440 from dlqs/dplanehook2
[mirror_frr.git] / bgpd / bgp_flowspec.c
index 17c41636de81c9c16b6d7db1f1a593dfbadee72a..341cfe9d07e86985bfdcd6be74a1d91d908e7957 100644 (file)
@@ -33,7 +33,8 @@
 #include "bgpd/bgp_debug.h"
 #include "bgpd/bgp_errors.h"
 
-static int bgp_fs_nlri_validate(uint8_t *nlri_content, uint32_t len)
+static int bgp_fs_nlri_validate(uint8_t *nlri_content, uint32_t len,
+                               afi_t afi)
 {
        uint32_t offset = 0;
        int type;
@@ -48,7 +49,15 @@ static int bgp_fs_nlri_validate(uint8_t *nlri_content, uint32_t len)
                        ret = bgp_flowspec_ip_address(
                                                BGP_FLOWSPEC_VALIDATE_ONLY,
                                                nlri_content + offset,
-                                               len - offset, NULL, &error);
+                                               len - offset, NULL, &error,
+                                               afi, NULL);
+                       break;
+               case FLOWSPEC_FLOW_LABEL:
+                       if (afi == AFI_IP)
+                               return -1;
+                       ret = bgp_flowspec_op_decode(BGP_FLOWSPEC_VALIDATE_ONLY,
+                                                  nlri_content + offset,
+                                                  len - offset, NULL, &error);
                        break;
                case FLOWSPEC_IP_PROTOCOL:
                case FLOWSPEC_PORT:
@@ -103,11 +112,6 @@ int bgp_nlri_parse_flowspec(struct peer *peer, struct attr *attr,
        afi = packet->afi;
        safi = packet->safi;
 
-       if (afi == AFI_IP6) {
-               flog_err(EC_LIB_DEVELOPMENT, "BGP flowspec IPv6 not supported");
-               return BGP_NLRI_PARSE_ERROR_FLOWSPEC_IPV6_NOT_SUPPORTED;
-       }
-
        if (packet->length >= FLOWSPEC_NLRI_SIZELIMIT_EXTENDED) {
                flog_err(EC_BGP_FLOWSPEC_PACKET,
                         "BGP flowspec nlri length maximum reached (%u)",
@@ -137,7 +141,7 @@ int bgp_nlri_parse_flowspec(struct peer *peer, struct attr *attr,
                                psize);
                        return BGP_NLRI_PARSE_ERROR_PACKET_OVERFLOW;
                }
-               if (bgp_fs_nlri_validate(pnt, psize) < 0) {
+               if (bgp_fs_nlri_validate(pnt, psize, afi) < 0) {
                        flog_err(
                                EC_BGP_FLOWSPEC_PACKET,
                                "Bad flowspec format or NLRI options not supported");
@@ -147,6 +151,7 @@ int bgp_nlri_parse_flowspec(struct peer *peer, struct attr *attr,
                p.prefixlen = 0;
                /* Flowspec encoding is in bytes */
                p.u.prefix_flowspec.prefixlen = psize;
+               p.u.prefix_flowspec.family = afi2family(afi);
                temp = XCALLOC(MTYPE_TMP, psize);
                memcpy(temp, pnt, psize);
                p.u.prefix_flowspec.ptr = (uintptr_t) temp;
@@ -161,7 +166,8 @@ int bgp_nlri_parse_flowspec(struct peer *peer, struct attr *attr,
                                               p.u.prefix_flowspec.ptr,
                                               p.u.prefix_flowspec.prefixlen,
                                               return_string,
-                                              NLRI_STRING_FORMAT_MIN, NULL);
+                                              NLRI_STRING_FORMAT_MIN, NULL,
+                                              afi);
                        snprintf(ec_string, sizeof(ec_string),
                                 "EC{none}");
                        if (attr && attr->ecommunity) {