]> git.proxmox.com Git - mirror_frr.git/blobdiff - ripd/rip_interface.c
bgpd: Remove warn to file an issue
[mirror_frr.git] / ripd / rip_interface.c
index 9282896c2845db2b1ffe77127033168d79069658..364e23c5e63b6d92b492c8c7039b7e89d12b3b3e 100644 (file)
@@ -34,6 +34,7 @@
 #include "filter.h"
 #include "sockopt.h"
 #include "privs.h"
+#include "lib_errors.h"
 
 #include "zebra/connected.h"
 
@@ -58,8 +59,6 @@ const struct message ri_version_msg[] = {{RI_RIP_VERSION_1, "1"},
                                         {RI_RIP_VERSION_NONE, "none"},
                                         {0}};
 
-extern struct zebra_privs_t ripd_privs;
-
 /* RIP enabled network vector. */
 vector rip_enable_interface;
 
@@ -135,7 +134,7 @@ void rip_interface_multicast_set(int sock, struct connected *connected)
 }
 
 /* Send RIP request packet to specified interface. */
-static void rip_request_interface_send(struct interface *ifp, u_char version)
+static void rip_request_interface_send(struct interface *ifp, uint8_t version)
 {
        struct sockaddr_in to;
 
@@ -516,14 +515,12 @@ static void rip_interface_reset(struct rip_interface *ri)
 
        ri->v2_broadcast = 0;
 
-       if (ri->auth_str) {
-               free(ri->auth_str);
-               ri->auth_str = NULL;
-       }
-       if (ri->key_chain) {
-               free(ri->key_chain);
-               ri->key_chain = NULL;
-       }
+       if (ri->auth_str)
+               XFREE(MTYPE_RIP_INTERFACE_STRING, ri->auth_str);
+
+       if (ri->key_chain)
+               XFREE(MTYPE_RIP_INTERFACE_STRING, ri->key_chain);
+
 
        ri->list[RIP_FILTER_IN] = NULL;
        ri->list[RIP_FILTER_OUT] = NULL;
@@ -561,7 +558,7 @@ int rip_if_down(struct interface *ifp)
                        if ((list = rp->info) != NULL)
                                for (ALL_LIST_ELEMENTS(list, listnode, nextnode,
                                                       rinfo))
-                                       if (rinfo->ifindex == ifp->ifindex)
+                                       if (rinfo->nh.ifindex == ifp->ifindex)
                                                rip_ecmp_delete(rinfo);
 
                ri = ifp->info;
@@ -593,6 +590,7 @@ void rip_if_down_all()
 static void rip_apply_address_add(struct connected *ifc)
 {
        struct prefix_ipv4 address;
+       struct nexthop nh;
        struct prefix *p;
 
        if (!rip)
@@ -604,18 +602,22 @@ static void rip_apply_address_add(struct connected *ifc)
        p = ifc->address;
 
        memset(&address, 0, sizeof(address));
+       memset(&nh, 0, sizeof(nh));
+
        address.family = p->family;
        address.prefix = p->u.prefix4;
        address.prefixlen = p->prefixlen;
        apply_mask_ipv4(&address);
 
+       nh.ifindex = ifc->ifp->ifindex;
+       nh.type = NEXTHOP_TYPE_IFINDEX;
+
        /* Check if this interface is RIP enabled or not
           or  Check if this address's prefix is RIP enabled */
        if ((rip_enable_if_lookup(ifc->ifp->name) >= 0)
            || (rip_enable_network_lookup2(ifc) >= 0))
                rip_redistribute_add(ZEBRA_ROUTE_CONNECT, RIP_ROUTE_INTERFACE,
-                                    &address, ifc->ifp->ifindex, NULL, 0, 0,
-                                    0);
+                                    &address, &nh, 0, 0, 0);
 }
 
 int rip_interface_address_add(int command, struct zclient *zclient,
@@ -822,7 +824,8 @@ static int rip_enable_if_add(const char *ifname)
        if (ret >= 0)
                return -1;
 
-       vector_set(rip_enable_interface, strdup(ifname));
+       vector_set(rip_enable_interface,
+                  XSTRDUP(MTYPE_RIP_INTERFACE_STRING, ifname));
 
        rip_enable_apply_all(); /* TODOVJ */
 
@@ -840,7 +843,7 @@ static int rip_enable_if_delete(const char *ifname)
                return -1;
 
        str = vector_slot(rip_enable_interface, index);
-       free(str);
+       XFREE(MTYPE_RIP_INTERFACE_STRING, str);
        vector_unset(rip_enable_interface, index);
 
        rip_enable_apply_all(); /* TODOVJ */
@@ -862,8 +865,9 @@ static int rip_interface_wakeup(struct thread *t)
 
        /* Join to multicast group. */
        if (rip_multicast_join(ifp, rip->sock) < 0) {
-               zlog_err("multicast join failed, interface %s not running",
-                        ifp->name);
+               flog_err_sys(LIB_ERR_SOCKET,
+                            "multicast join failed, interface %s not running",
+                            ifp->name);
                return 0;
        }
 
@@ -881,6 +885,9 @@ static void rip_connect_set(struct interface *ifp, int set)
        struct listnode *node, *nnode;
        struct connected *connected;
        struct prefix_ipv4 address;
+       struct nexthop nh;
+
+       memset(&nh, 0, sizeof(nh));
 
        for (ALL_LIST_ELEMENTS(ifp->connected, node, nnode, connected)) {
                struct prefix *p;
@@ -894,24 +901,24 @@ static void rip_connect_set(struct interface *ifp, int set)
                address.prefixlen = p->prefixlen;
                apply_mask_ipv4(&address);
 
+               nh.ifindex = connected->ifp->ifindex;
+               nh.type = NEXTHOP_TYPE_IFINDEX;
                if (set) {
                        /* Check once more wether this prefix is within a
                         * "network IF_OR_PREF" one */
                        if ((rip_enable_if_lookup(connected->ifp->name) >= 0)
                            || (rip_enable_network_lookup2(connected) >= 0))
-                               rip_redistribute_add(
-                                       ZEBRA_ROUTE_CONNECT,
-                                       RIP_ROUTE_INTERFACE, &address,
-                                       connected->ifp->ifindex, NULL, 0, 0, 0);
+                               rip_redistribute_add(ZEBRA_ROUTE_CONNECT,
+                                                    RIP_ROUTE_INTERFACE,
+                                                    &address, &nh, 0, 0, 0);
                } else {
                        rip_redistribute_delete(ZEBRA_ROUTE_CONNECT,
                                                RIP_ROUTE_INTERFACE, &address,
                                                connected->ifp->ifindex);
                        if (rip_redistribute_check(ZEBRA_ROUTE_CONNECT))
-                               rip_redistribute_add(
-                                       ZEBRA_ROUTE_CONNECT,
-                                       RIP_ROUTE_REDISTRIBUTE, &address,
-                                       connected->ifp->ifindex, NULL, 0, 0, 0);
+                               rip_redistribute_add(ZEBRA_ROUTE_CONNECT,
+                                                    RIP_ROUTE_REDISTRIBUTE,
+                                                    &address, &nh, 0, 0, 0);
                }
        }
 }
@@ -1056,7 +1063,7 @@ void rip_clean_network()
        /* rip_enable_interface. */
        for (i = 0; i < vector_active(rip_enable_interface); i++)
                if ((str = vector_slot(rip_enable_interface, i)) != NULL) {
-                       free(str);
+                       XFREE(MTYPE_RIP_INTERFACE_STRING, str);
                        vector_slot(rip_enable_interface, i) = NULL;
                }
 }
@@ -1104,7 +1111,8 @@ static int rip_passive_nondefault_set(struct vty *vty, const char *ifname)
        if (rip_passive_nondefault_lookup(ifname) >= 0)
                return CMD_WARNING_CONFIG_FAILED;
 
-       vector_set(Vrip_passive_nondefault, strdup(ifname));
+       vector_set(Vrip_passive_nondefault,
+                  XSTRDUP(MTYPE_RIP_INTERFACE_STRING, ifname));
 
        rip_passive_interface_apply_all();
 
@@ -1121,7 +1129,7 @@ static int rip_passive_nondefault_unset(struct vty *vty, const char *ifname)
                return CMD_WARNING_CONFIG_FAILED;
 
        str = vector_slot(Vrip_passive_nondefault, i);
-       free(str);
+       XFREE(MTYPE_RIP_INTERFACE_STRING, str);
        vector_unset(Vrip_passive_nondefault, i);
 
        rip_passive_interface_apply_all();
@@ -1137,7 +1145,7 @@ void rip_passive_nondefault_clean(void)
 
        for (i = 0; i < vector_active(Vrip_passive_nondefault); i++)
                if ((str = vector_slot(Vrip_passive_nondefault, i)) != NULL) {
-                       free(str);
+                       XFREE(MTYPE_RIP_INTERFACE_STRING, str);
                        vector_slot(Vrip_passive_nondefault, i) = NULL;
                }
        rip_passive_interface_apply_all();
@@ -1523,9 +1531,9 @@ DEFUN (ip_rip_authentication_string,
        }
 
        if (ri->auth_str)
-               free(ri->auth_str);
+               XFREE(MTYPE_RIP_INTERFACE_STRING, ri->auth_str);
 
-       ri->auth_str = strdup(argv[idx_line]->arg);
+       ri->auth_str = XSTRDUP(MTYPE_RIP_INTERFACE_STRING, argv[idx_line]->arg);
 
        return CMD_SUCCESS;
 }
@@ -1546,9 +1554,7 @@ DEFUN (no_ip_rip_authentication_string,
        ri = ifp->info;
 
        if (ri->auth_str)
-               free(ri->auth_str);
-
-       ri->auth_str = NULL;
+               XFREE(MTYPE_RIP_INTERFACE_STRING, ri->auth_str);
 
        return CMD_SUCCESS;
 }
@@ -1575,9 +1581,10 @@ DEFUN (ip_rip_authentication_key_chain,
        }
 
        if (ri->key_chain)
-               free(ri->key_chain);
+               XFREE(MTYPE_RIP_INTERFACE_STRING, ri->key_chain);
 
-       ri->key_chain = strdup(argv[idx_line]->arg);
+       ri->key_chain =
+               XSTRDUP(MTYPE_RIP_INTERFACE_STRING, argv[idx_line]->arg);
 
        return CMD_SUCCESS;
 }
@@ -1598,9 +1605,7 @@ DEFUN (no_ip_rip_authentication_key_chain,
        ri = ifp->info;
 
        if (ri->key_chain)
-               free(ri->key_chain);
-
-       ri->key_chain = NULL;
+               XFREE(MTYPE_RIP_INTERFACE_STRING, ri->key_chain);
 
        return CMD_SUCCESS;
 }