]> git.proxmox.com Git - mirror_frr.git/commitdiff
zebra: Make prefix length check return error
authorStephen Worley <sworley@cumulusnetworks.com>
Thu, 26 Jul 2018 19:10:53 +0000 (15:10 -0400)
committerStephen Worley <sworley@cumulusnetworks.com>
Thu, 26 Jul 2018 19:10:53 +0000 (15:10 -0400)
Prefix length validation checks should be returning an error
rather than 0. Switch to that and make them error messages.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
zebra/if_netlink.c
zebra/rt_netlink.c

index f03252369fa52b9aa7cd6dddf6bb84717d34b11f..a8cf5e31b638dddab1316ff833c5d1551029c6c5 100644 (file)
@@ -992,10 +992,10 @@ int netlink_interface_addr(struct nlmsghdr *h, ns_id_t ns_id, int startup)
        /* Register interface address to the interface. */
        if (ifa->ifa_family == AF_INET) {
                if (ifa->ifa_prefixlen > IPV4_MAX_BITLEN) {
-                       zlog_warn(
+                       zlog_err(
                                "Invalid prefix length: %u received from kernel interface addr change: %u",
                                ifa->ifa_prefixlen, h->nlmsg_type);
-                       return 0;
+                       return -1;
                }
                if (h->nlmsg_type == RTM_NEWADDR)
                        connected_add_ipv4(ifp, flags, (struct in_addr *)addr,
@@ -1008,10 +1008,10 @@ int netlink_interface_addr(struct nlmsghdr *h, ns_id_t ns_id, int startup)
        }
        if (ifa->ifa_family == AF_INET6) {
                if (ifa->ifa_prefixlen > IPV6_MAX_BITLEN) {
-                       zlog_warn(
+                       zlog_err(
                                "Invalid prefix length: %u received from kernel interface addr change: %u",
                                ifa->ifa_prefixlen, h->nlmsg_type);
-                       return 0;
+                       return -1;
                }
                if (h->nlmsg_type == RTM_NEWADDR) {
                        /* Only consider valid addresses; we'll not get a
index f396044bb4cfdd0617426d3f28432080648e2ecc..6eeede6f6064c3d22616bdd10fbe641e0b111185 100644 (file)
@@ -385,10 +385,10 @@ static int netlink_route_change_read_unicast(struct nlmsghdr *h, ns_id_t ns_id,
        if (rtm->rtm_family == AF_INET) {
                p.family = AF_INET;
                if (rtm->rtm_dst_len > IPV4_MAX_BITLEN) {
-                       zlog_warn(
+                       zlog_err(
                                "Invalid destination prefix length: %u received from kernel route change",
                                rtm->rtm_dst_len);
-                       return 0;
+                       return -1;
                }
                memcpy(&p.u.prefix4, dest, 4);
                p.prefixlen = rtm->rtm_dst_len;
@@ -399,20 +399,20 @@ static int netlink_route_change_read_unicast(struct nlmsghdr *h, ns_id_t ns_id,
        } else if (rtm->rtm_family == AF_INET6) {
                p.family = AF_INET6;
                if (rtm->rtm_dst_len > IPV6_MAX_BITLEN) {
-                       zlog_warn(
+                       zlog_err(
                                "Invalid destination prefix length: %u received from kernel route change",
                                rtm->rtm_dst_len);
-                       return 0;
+                       return -1;
                }
                memcpy(&p.u.prefix6, dest, 16);
                p.prefixlen = rtm->rtm_dst_len;
 
                src_p.family = AF_INET6;
                if (rtm->rtm_src_len > IPV6_MAX_BITLEN) {
-                       zlog_warn(
+                       zlog_err(
                                "Invalid source prefix length: %u received from kernel route change",
                                rtm->rtm_src_len);
-                       return 0;
+                       return -1;
                }
                memcpy(&src_p.prefix, src, 16);
                src_p.prefixlen = rtm->rtm_src_len;