]> git.proxmox.com Git - mirror_frr.git/blobdiff - bgpd/bgp_flowspec.c
Merge pull request #5793 from ton31337/fix/formatting_show_bgp_summary_failed
[mirror_frr.git] / bgpd / bgp_flowspec.c
index e29508bf3680d9e946bb77db9b40cc593a947386..9554638735f163f68ec77a537806259d400c517a 100644 (file)
@@ -18,9 +18,9 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include "math.h"
-
 #include <zebra.h>
+#include <math.h>
+
 #include "prefix.h"
 #include "lib_errors.h"
 
@@ -104,16 +104,15 @@ int bgp_nlri_parse_flowspec(struct peer *peer, struct attr *attr,
        safi = packet->safi;
 
        if (afi == AFI_IP6) {
-               flog_err(LIB_ERR_DEVELOPMENT,
-                         "BGP flowspec IPv6 not supported");
-               return -1;
+               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) {
-               flog_err(BGP_ERR_FLOWSPEC_PACKET,
-                         "BGP flowspec nlri length maximum reached (%u)",
-                         packet->length);
-               return -1;
+               flog_err(EC_BGP_FLOWSPEC_PACKET,
+                        "BGP flowspec nlri length maximum reached (%u)",
+                        packet->length);
+               return BGP_NLRI_PARSE_ERROR_FLOWSPEC_NLRI_SIZELIMIT;
        }
 
        for (; pnt < lim; pnt += psize) {
@@ -122,21 +121,23 @@ int bgp_nlri_parse_flowspec(struct peer *peer, struct attr *attr,
 
                /* All FlowSpec NLRI begin with length. */
                if (pnt + 1 > lim)
-                       return -1;
+                       return BGP_NLRI_PARSE_ERROR_PACKET_OVERFLOW;
 
                psize = *pnt++;
 
                /* When packet overflow occur return immediately. */
                if (pnt + psize > lim) {
-                       flog_err(BGP_ERR_FLOWSPEC_PACKET,
-                                 "Flowspec NLRI length inconsistent ( size %u seen)",
-                                 psize);
-                       return -1;
+                       flog_err(
+                               EC_BGP_FLOWSPEC_PACKET,
+                               "Flowspec NLRI length inconsistent ( size %u seen)",
+                               psize);
+                       return BGP_NLRI_PARSE_ERROR_PACKET_OVERFLOW;
                }
                if (bgp_fs_nlri_validate(pnt, psize) < 0) {
-                       flog_err(BGP_ERR_FLOWSPEC_PACKET,
-                                 "Bad flowspec format or NLRI options not supported");
-                       return -1;
+                       flog_err(
+                               EC_BGP_FLOWSPEC_PACKET,
+                               "Bad flowspec format or NLRI options not supported");
+                       return BGP_NLRI_PARSE_ERROR_FLOWSPEC_BAD_FORMAT;
                }
                p.family = AF_FLOWSPEC;
                p.prefixlen = 0;
@@ -188,11 +189,11 @@ int bgp_nlri_parse_flowspec(struct peer *peer, struct attr *attr,
                                           ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL,
                                           NULL, NULL, 0, NULL);
                if (ret) {
-                       flog_err(BGP_ERR_FLOWSPEC_INSTALLATION,
-                                 "Flowspec NLRI failed to be %s.",
-                                 attr ? "added" : "withdrawn");
-                       return -1;
+                       flog_err(EC_BGP_FLOWSPEC_INSTALLATION,
+                                "Flowspec NLRI failed to be %s.",
+                                attr ? "added" : "withdrawn");
+                       return BGP_NLRI_PARSE_ERROR;
                }
        }
-       return 0;
+       return BGP_NLRI_PARSE_OK;
 }