]> git.proxmox.com Git - mirror_frr.git/blobdiff - bgpd/bgp_pbr.c
Merge pull request #5686 from qlyoung/fix-bgp-fqdn-capability-leak
[mirror_frr.git] / bgpd / bgp_pbr.c
index 8852e46686277959d70f1111da5ba10bfd000033..14f5fefb2020955cf544a93448bd857a8e1e3c62 100644 (file)
@@ -698,6 +698,7 @@ int bgp_pbr_build_and_validate_entry(struct prefix *p,
        int valid_prefix = 0;
        afi_t afi = AFI_IP;
        struct bgp_pbr_entry_action *api_action_redirect_ip = NULL;
+       bool discard_action_found = false;
 
        /* extract match from flowspec entries */
        ret = bgp_flowspec_match_rules_fill((uint8_t *)p->u.prefix_flowspec.ptr,
@@ -705,7 +706,7 @@ int bgp_pbr_build_and_validate_entry(struct prefix *p,
        if (ret < 0)
                return -1;
        /* extract actiosn from flowspec ecom list */
-       if (path && path->attr && path->attr->ecommunity) {
+       if (path && path->attr->ecommunity) {
                ecom = path->attr->ecommunity;
                for (i = 0; i < ecom->size; i++) {
                        ecom_eval = (struct ecommunity_val *)
@@ -805,10 +806,22 @@ int bgp_pbr_build_and_validate_entry(struct prefix *p,
                                                                 api_action);
                                if (ret != 0)
                                        continue;
+                               if ((api_action->action == ACTION_TRAFFICRATE) &&
+                                   api->actions[i].u.r.rate == 0)
+                                       discard_action_found = true;
                        }
                        api->action_num++;
                }
        }
+       /* if ECOMMUNITY_TRAFFIC_RATE = 0 as action
+        * then reduce the API action list to that action
+        */
+       if (api->action_num > 1 && discard_action_found) {
+               api->action_num = 1;
+               memset(&api->actions[0], 0,
+                      sizeof(struct bgp_pbr_entry_action));
+               api->actions[0].action = ACTION_TRAFFICRATE;
+       }
 
        /* validate if incoming matc/action is compatible
         * with our policy routing engine
@@ -1712,7 +1725,7 @@ static void bgp_pbr_policyroute_remove_from_zebra_unit(
                        temp.type = IPSET_NET_NET;
        }
        if (bpf->vrf_id == VRF_UNKNOWN) /* XXX case BGP destroy */
-               temp.vrf_id = 0;
+               temp.vrf_id = VRF_DEFAULT;
        else
                temp.vrf_id = bpf->vrf_id;
        bpme = &temp2;