summaryrefslogtreecommitdiff
path: root/zebra/interface.c
diff options
context:
space:
mode:
Diffstat (limited to 'zebra/interface.c')
-rw-r--r--zebra/interface.c53
1 files changed, 44 insertions, 9 deletions
diff --git a/zebra/interface.c b/zebra/interface.c
index 7795d34d0b..6f59a2d399 100644
--- a/zebra/interface.c
+++ b/zebra/interface.c
@@ -181,7 +181,7 @@ static int if_zebra_delete_hook(struct interface *ifp)
}
/* Build the table key */
-static void if_build_key(u_int32_t ifindex, struct prefix *p)
+static void if_build_key(uint32_t ifindex, struct prefix *p)
{
p->family = AF_INET;
p->prefixlen = IPV4_MAX_BITLEN;
@@ -221,7 +221,7 @@ void if_unlink_per_ns(struct interface *ifp)
/* Look up an interface by identifier within a NS */
struct interface *if_lookup_by_index_per_ns(struct zebra_ns *ns,
- u_int32_t ifindex)
+ uint32_t ifindex)
{
struct prefix p;
struct route_node *rn;
@@ -252,6 +252,30 @@ struct interface *if_lookup_by_name_per_ns(struct zebra_ns *ns,
return NULL;
}
+/* this function must be used only if the vrf backend
+ * is a netns backend
+ */
+struct interface *if_lookup_by_name_not_ns(ns_id_t ns_id,
+ const char *ifname)
+{
+ struct interface *ifp;
+ struct ns *ns;
+
+ RB_FOREACH (ns, ns_head, &ns_tree) {
+ if (ns->ns_id == ns_id)
+ continue;
+ /* if_delete_update has removed interface
+ * from zns->if_table
+ * so to look for interface, use the vrf list
+ */
+ ifp = if_lookup_by_name(ifname, (vrf_id_t)ns->ns_id);
+ if (!ifp)
+ continue;
+ return ifp;
+ }
+ return NULL;
+}
+
const char *ifindex2ifname_per_ns(struct zebra_ns *zns, unsigned int ifindex)
{
struct interface *ifp;
@@ -787,7 +811,7 @@ void if_handle_vrf_change(struct interface *ifp, vrf_id_t vrf_id)
rib_update(ifp->vrf_id, RIB_UPDATE_IF_CHANGE);
}
-static void ipv6_ll_address_to_mac(struct in6_addr *address, u_char *mac)
+static void ipv6_ll_address_to_mac(struct in6_addr *address, uint8_t *mac)
{
mac[0] = address->s6_addr[8] ^ 0x02;
mac[1] = address->s6_addr[9];
@@ -801,6 +825,7 @@ void if_nbr_ipv6ll_to_ipv4ll_neigh_update(struct interface *ifp,
struct in6_addr *address, int add)
{
struct zebra_vrf *zvrf = vrf_info_lookup(ifp->vrf_id);
+ struct zebra_if *zif = ifp->info;
char buf[16] = "169.254.0.1";
struct in_addr ipv4_ll;
char mac[6];
@@ -808,7 +833,7 @@ void if_nbr_ipv6ll_to_ipv4ll_neigh_update(struct interface *ifp,
inet_pton(AF_INET, buf, &ipv4_ll);
- ipv6_ll_address_to_mac(address, (u_char *)mac);
+ ipv6_ll_address_to_mac(address, (uint8_t *)mac);
ns_id = zvrf->zns->ns_id;
/*
@@ -821,6 +846,16 @@ void if_nbr_ipv6ll_to_ipv4ll_neigh_update(struct interface *ifp,
/* Add arp record */
kernel_neigh_update(add, ifp->ifindex, ipv4_ll.s_addr, mac, 6, ns_id);
+
+ /*
+ * We need to note whether or not we originated a v6
+ * neighbor entry for this interface. So that when
+ * someone unwisely accidently deletes this entry
+ * we can shove it back in.
+ */
+ zif->v6_2_v4_ll_neigh_entry = !!add;
+ memcpy(&zif->v6_2_v4_ll_addr6, address, sizeof(*address));
+
zvrf->neigh_updates++;
}
@@ -1857,7 +1892,7 @@ DEFUN (link_params_metric,
int idx_number = 1;
VTY_DECLVAR_CONTEXT(interface, ifp);
struct if_link_params *iflp = if_link_params_get(ifp);
- u_int32_t metric;
+ uint32_t metric;
metric = strtoul(argv[idx_number]->arg, NULL, 10);
@@ -2045,7 +2080,7 @@ DEFUN (link_params_inter_as,
VTY_DECLVAR_CONTEXT(interface, ifp);
struct if_link_params *iflp = if_link_params_get(ifp);
struct in_addr addr;
- u_int32_t as;
+ uint32_t as;
if (!inet_aton(argv[idx_ipv4]->arg, &addr)) {
vty_out(vty, "Please specify Router-Addr by A.B.C.D\n");
@@ -2104,7 +2139,7 @@ DEFUN (link_params_delay,
"Maximum delay in micro-second as decimal (0...16777215)\n")
{
/* Get and Check new delay values */
- u_int32_t delay = 0, low = 0, high = 0;
+ uint32_t delay = 0, low = 0, high = 0;
delay = strtoul(argv[1]->arg, NULL, 10);
if (argc == 6) {
low = strtoul(argv[3]->arg, NULL, 10);
@@ -2113,7 +2148,7 @@ DEFUN (link_params_delay,
VTY_DECLVAR_CONTEXT(interface, ifp);
struct if_link_params *iflp = if_link_params_get(ifp);
- u_int8_t update = 0;
+ uint8_t update = 0;
if (argc == 2) {
/* Check new delay value against old Min and Max delays if set
@@ -2199,7 +2234,7 @@ DEFUN (link_params_delay_var,
int idx_number = 1;
VTY_DECLVAR_CONTEXT(interface, ifp);
struct if_link_params *iflp = if_link_params_get(ifp);
- u_int32_t value;
+ uint32_t value;
value = strtoul(argv[idx_number]->arg, NULL, 10);