]> git.proxmox.com Git - mirror_frr.git/blobdiff - bgpd/bgp_flowspec_util.c
Merge pull request #3502 from donaldsharp/socket_to_me_baby
[mirror_frr.git] / bgpd / bgp_flowspec_util.c
index c7432773b9e2839135d0c4cc00a63a2de4961727..c6386dcdb56df55dab52f963dbfe97d9b565b28f 100644 (file)
@@ -68,9 +68,8 @@ static int bgp_flowspec_call_non_opaque_decode(uint8_t *nlri_content, int len,
                             len,
                             mval, error);
        if (*error < 0)
-               zlog_ferr(BGP_ERR_FLOWSPEC_PACKET,
-                         "%s: flowspec_op_decode error %d",
-                         __func__, *error);
+               flog_err(EC_BGP_FLOWSPEC_PACKET,
+                        "%s: flowspec_op_decode error %d", __func__, *error);
        else
                *match_num = *error;
        return ret;
@@ -447,11 +446,20 @@ int bgp_flowspec_match_rules_fill(uint8_t *nlri_content, int len,
                                        len - offset,
                                        prefix, &error);
                        if (error < 0)
-                               zlog_ferr(BGP_ERR_FLOWSPEC_PACKET,
-                                         "%s: flowspec_ip_address error %d",
-                                         __func__, error);
-                       else
-                               bpem->match_bitmask |= bitmask;
+                               flog_err(EC_BGP_FLOWSPEC_PACKET,
+                                        "%s: flowspec_ip_address error %d",
+                                        __func__, error);
+                       else {
+                               /* if src or dst address is 0.0.0.0,
+                                * ignore that rule
+                                */
+                               if (prefix->family == AF_INET
+                                   && prefix->u.prefix4.s_addr == 0)
+                                       memset(prefix, 0,
+                                              sizeof(struct prefix));
+                               else
+                                       bpem->match_bitmask |= bitmask;
+                       }
                        offset += ret;
                        break;
                case FLOWSPEC_IP_PROTOCOL:
@@ -542,9 +550,10 @@ int bgp_flowspec_match_rules_fill(uint8_t *nlri_content, int len,
                                        len - offset,
                                        &bpem->tcpflags, &error);
                        if (error < 0)
-                               zlog_ferr(BGP_ERR_FLOWSPEC_PACKET,
-                                         "%s: flowspec_tcpflags_decode error %d",
-                                         __func__, error);
+                               flog_err(
+                                       EC_BGP_FLOWSPEC_PACKET,
+                                       "%s: flowspec_tcpflags_decode error %d",
+                                       __func__, error);
                        else
                                bpem->match_tcpflags_num = error;
                        /* contains the number of slots used */
@@ -557,16 +566,17 @@ int bgp_flowspec_match_rules_fill(uint8_t *nlri_content, int len,
                                        len - offset, &bpem->fragment,
                                        &error);
                        if (error < 0)
-                               zlog_ferr(BGP_ERR_FLOWSPEC_PACKET,
-                                         "%s: flowspec_fragment_type_decode error %d",
-                                         __func__, error);
+                               flog_err(
+                                       EC_BGP_FLOWSPEC_PACKET,
+                                       "%s: flowspec_fragment_type_decode error %d",
+                                       __func__, error);
                        else
                                bpem->match_fragment_num = error;
                        offset += ret;
                        break;
                default:
-                       zlog_ferr(LIB_ERR_DEVELOPMENT, "%s: unknown type %d\n",
-                                 __func__, type);
+                       flog_err(EC_LIB_DEVELOPMENT, "%s: unknown type %d\n",
+                                __func__, type);
                }
        }
        return error;