#include "filter.h"
#include "sockopt.h"
#include "privs.h"
+#include "lib_errors.h"
#include "zebra/connected.h"
{RI_RIP_VERSION_NONE, "none"},
{0}};
-extern struct zebra_privs_t ripd_privs;
-
/* RIP enabled network vector. */
vector rip_enable_interface;
}
/* 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;
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;
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;
static void rip_apply_address_add(struct connected *ifc)
{
struct prefix_ipv4 address;
+ struct nexthop nh;
struct prefix *p;
if (!rip)
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,
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 */
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 */
/* 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;
}
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;
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);
}
}
}
/* 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;
}
}
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();
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();
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();
}
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;
}
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;
}
}
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;
}
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;
}