#include "zebra/debug.h"
#include "zebra/rib.h"
#include "zebra/zapi_msg.h"
+#include "zebra/zebra_ns.h"
#include "zebra/zebra_vrf.h"
#include "zebra/zebra_errors.h"
#include "zebra/zebra_router.h"
RTADV_READ
};
-static void rtadv_event(struct zebra_vrf *, enum rtadv_event, int);
+static void rtadv_event(struct zebra_ns *, enum rtadv_event, int);
static int if_join_all_router(int, struct interface *);
static int if_leave_all_router(int, struct interface *);
-static int rtadv_increment_received(struct zebra_vrf *zvrf, ifindex_t *ifindex)
+static int rtadv_increment_received(struct zebra_ns *zns, ifindex_t *ifindex)
{
int ret = -1;
struct interface *iface;
struct zebra_if *zif;
- iface = if_lookup_by_index(*ifindex, zvrf->vrf->vrf_id);
+ iface = if_lookup_by_index_per_ns(zns, *ifindex);
if (iface && iface->info) {
zif = iface->info;
zif->ra_rcvd++;
return ret;
}
-static int rtadv_recv_packet(struct zebra_vrf *zvrf, int sock, uint8_t *buf,
+static int rtadv_recv_packet(struct zebra_ns *zns, int sock, uint8_t *buf,
int buflen, struct sockaddr_in6 *from,
ifindex_t *ifindex, int *hoplimit)
{
}
}
- rtadv_increment_received(zvrf, ifindex);
+ rtadv_increment_received(zns, ifindex);
return ret;
}
static int rtadv_timer(struct thread *thread)
{
- struct zebra_vrf *zvrf = THREAD_ARG(thread);
+ struct zebra_ns *zns = THREAD_ARG(thread);
struct vrf *vrf;
struct interface *ifp;
struct zebra_if *zif;
int period;
- zvrf->rtadv.ra_timer = NULL;
- if (zvrf->rtadv.adv_msec_if_count == 0) {
+ zrouter.rtadv.ra_timer = NULL;
+ if (zrouter.rtadv.adv_msec_if_count == 0) {
period = 1000; /* 1 s */
- rtadv_event(zvrf, RTADV_TIMER, 1 /* 1 s */);
+ rtadv_event(zns, RTADV_TIMER, 1 /* 1 s */);
} else {
period = 10; /* 10 ms */
- rtadv_event(zvrf, RTADV_TIMER_MSEC, 10 /* 10 ms */);
+ rtadv_event(zns, RTADV_TIMER_MSEC, 10 /* 10 ms */);
}
RB_FOREACH (vrf, vrf_id_head, &vrfs_by_id)
"Fast RA Rexmit on interface %s",
ifp->name);
- rtadv_send_packet(zvrf->rtadv.sock,
+ rtadv_send_packet(zrouter.rtadv.sock,
ifp);
} else {
zif->rtadv.AdvIntervalTimer -= period;
zif->rtadv
.MaxRtrAdvInterval;
rtadv_send_packet(
- zvrf->rtadv.sock,
+ zrouter.rtadv.sock,
ifp);
}
}
static void rtadv_process_solicit(struct interface *ifp)
{
struct zebra_vrf *zvrf = vrf_info_lookup(ifp->vrf_id);
+ struct zebra_ns *zns = zvrf->zns;
- assert(zvrf);
- rtadv_send_packet(zvrf->rtadv.sock, ifp);
+ assert(zns);
+ rtadv_send_packet(zrouter.rtadv.sock, ifp);
}
/*
static void rtadv_process_packet(uint8_t *buf, unsigned int len,
ifindex_t ifindex, int hoplimit,
struct sockaddr_in6 *from,
- struct zebra_vrf *zvrf)
+ struct zebra_ns *zns)
{
struct icmp6_hdr *icmph;
struct interface *ifp;
inet_ntop(AF_INET6, &from->sin6_addr, addr_str, INET6_ADDRSTRLEN);
/* Interface search. */
- ifp = if_lookup_by_index(ifindex, zvrf->vrf->vrf_id);
+ ifp = if_lookup_by_index_per_ns(zns, ifindex);
if (ifp == NULL) {
flog_warn(EC_ZEBRA_UNKNOWN_INTERFACE,
"RA/RS received on unknown IF %u from %s", ifindex,
struct sockaddr_in6 from;
ifindex_t ifindex = 0;
int hoplimit = -1;
- struct zebra_vrf *zvrf = THREAD_ARG(thread);
+ struct zebra_ns *zns = THREAD_ARG(thread);
sock = THREAD_FD(thread);
- zvrf->rtadv.ra_read = NULL;
+ zrouter.rtadv.ra_read = NULL;
/* Register myself. */
- rtadv_event(zvrf, RTADV_READ, sock);
+ rtadv_event(zns, RTADV_READ, sock);
- len = rtadv_recv_packet(zvrf, sock, buf, sizeof(buf), &from, &ifindex,
+ len = rtadv_recv_packet(zns, sock, buf, sizeof(buf), &from, &ifindex,
&hoplimit);
if (len < 0) {
return len;
}
- rtadv_process_packet(buf, (unsigned)len, ifindex, hoplimit, &from, zvrf);
+ rtadv_process_packet(buf, (unsigned)len, ifindex, hoplimit, &from, zns);
return 0;
}
{
struct zebra_if *zif;
struct zebra_vrf *zvrf;
+ struct zebra_ns *zns;
zif = ifp->info;
zvrf = vrf_info_lookup(ifp->vrf_id);
+ zns = zvrf->zns;
if (status == RA_SUPPRESS) {
/* RA is currently enabled */
if (zif->rtadv.AdvSendAdvertisements) {
zif->rtadv.AdvSendAdvertisements = 0;
zif->rtadv.AdvIntervalTimer = 0;
- zvrf->rtadv.adv_if_count--;
+ zrouter.rtadv.adv_if_count--;
- if_leave_all_router(zvrf->rtadv.sock, ifp);
+ if_leave_all_router(zrouter.rtadv.sock, ifp);
- if (zvrf->rtadv.adv_if_count == 0)
- rtadv_event(zvrf, RTADV_STOP, 0);
+ if (zrouter.rtadv.adv_if_count == 0)
+ rtadv_event(zns, RTADV_STOP, 0);
}
} else {
if (!zif->rtadv.AdvSendAdvertisements) {
zif->rtadv.AdvSendAdvertisements = 1;
zif->rtadv.AdvIntervalTimer = 0;
- zvrf->rtadv.adv_if_count++;
+ zrouter.rtadv.adv_if_count++;
if (zif->rtadv.MaxRtrAdvInterval >= 1000) {
/* Enable Fast RA only when RA interval is in
RTADV_NUM_FAST_REXMITS;
}
- if_join_all_router(zvrf->rtadv.sock, ifp);
+ if_join_all_router(zrouter.rtadv.sock, ifp);
- if (zvrf->rtadv.adv_if_count == 1)
- rtadv_event(zvrf, RTADV_START,
- zvrf->rtadv.sock);
+ if (zrouter.rtadv.adv_if_count == 1)
+ rtadv_event(zns, RTADV_START,
+ zrouter.rtadv.sock);
}
}
}
zebra_route_string(client->proto), ra_interval);
/* Locate interface and check VRF match. */
- ifp = if_lookup_by_index(ifindex, zvrf->vrf->vrf_id);
+ ifp = if_lookup_by_index_per_ns(zebra_ns_lookup(NS_DEFAULT), ifindex);
if (!ifp) {
flog_warn(EC_ZEBRA_UNKNOWN_INTERFACE,
"%u: IF %u RA %s client %s - interface unknown",
VTY_DECLVAR_CONTEXT(interface, ifp);
unsigned interval;
struct zebra_if *zif = ifp->info;
- struct zebra_vrf *zvrf;
-
- zvrf = vrf_info_lookup(ifp->vrf_id);
interval = strtoul(argv[idx_number]->arg, NULL, 10);
if ((zif->rtadv.AdvDefaultLifetime != -1
}
if (zif->rtadv.MaxRtrAdvInterval % 1000)
- zvrf->rtadv.adv_msec_if_count--;
+ zrouter.rtadv.adv_msec_if_count--;
if (interval % 1000)
- zvrf->rtadv.adv_msec_if_count++;
+ zrouter.rtadv.adv_msec_if_count++;
SET_FLAG(zif->rtadv.ra_configured, VTY_RA_INTERVAL_CONFIGURED);
zif->rtadv.MaxRtrAdvInterval = interval;
VTY_DECLVAR_CONTEXT(interface, ifp);
unsigned interval;
struct zebra_if *zif = ifp->info;
- struct zebra_vrf *zvrf;
-
- zvrf = vrf_info_lookup(ifp->vrf_id);
interval = strtoul(argv[idx_number]->arg, NULL, 10);
if ((zif->rtadv.AdvDefaultLifetime != -1
}
if (zif->rtadv.MaxRtrAdvInterval % 1000)
- zvrf->rtadv.adv_msec_if_count--;
+ zrouter.rtadv.adv_msec_if_count--;
/* convert to milliseconds */
interval = interval * 1000;
{
VTY_DECLVAR_CONTEXT(interface, ifp);
struct zebra_if *zif = ifp->info;
- struct zebra_vrf *zvrf = NULL;
-
- zvrf = vrf_info_lookup(ifp->vrf_id);
if (zif->rtadv.MaxRtrAdvInterval % 1000)
- zvrf->rtadv.adv_msec_if_count--;
+ zrouter.rtadv.adv_msec_if_count--;
UNSET_FLAG(zif->rtadv.ra_configured, VTY_RA_INTERVAL_CONFIGURED);
}
-static void rtadv_event(struct zebra_vrf *zvrf, enum rtadv_event event, int val)
+static void rtadv_event(struct zebra_ns *zns, enum rtadv_event event, int val)
{
- struct rtadv *rtadv = &zvrf->rtadv;
+ struct rtadv *rtadv = &zrouter.rtadv;
switch (event) {
case RTADV_START:
- thread_add_read(zrouter.master, rtadv_read, zvrf, val,
+ thread_add_read(zrouter.master, rtadv_read, zns, val,
&rtadv->ra_read);
- thread_add_event(zrouter.master, rtadv_timer, zvrf, 0,
+ thread_add_event(zrouter.master, rtadv_timer, zns, 0,
&rtadv->ra_timer);
break;
case RTADV_STOP:
}
break;
case RTADV_TIMER:
- thread_add_timer(zrouter.master, rtadv_timer, zvrf, val,
+ thread_add_timer(zrouter.master, rtadv_timer, zns, val,
&rtadv->ra_timer);
break;
case RTADV_TIMER_MSEC:
- thread_add_timer_msec(zrouter.master, rtadv_timer, zvrf, val,
+ thread_add_timer_msec(zrouter.master, rtadv_timer, zns, val,
&rtadv->ra_timer);
break;
case RTADV_READ:
- thread_add_read(zrouter.master, rtadv_read, zvrf, val,
+ thread_add_read(zrouter.master, rtadv_read, zns, val,
&rtadv->ra_read);
break;
default:
return;
}
-void rtadv_init(struct zebra_vrf *zvrf)
+void rtadv_init(struct zebra_ns *zns)
{
- zvrf->rtadv.sock = rtadv_make_socket(zvrf->zns->ns_id);
+ zrouter.rtadv.sock = rtadv_make_socket(zns->ns_id);
}
-void rtadv_terminate(struct zebra_vrf *zvrf)
+void rtadv_terminate(struct zebra_ns *zns)
{
- rtadv_event(zvrf, RTADV_STOP, 0);
- if (zvrf->rtadv.sock >= 0) {
- close(zvrf->rtadv.sock);
- zvrf->rtadv.sock = -1;
+ rtadv_event(zns, RTADV_STOP, 0);
+ if (zrouter.rtadv.sock >= 0) {
+ close(zrouter.rtadv.sock);
+ zrouter.rtadv.sock = -1;
}
- zvrf->rtadv.adv_if_count = 0;
- zvrf->rtadv.adv_msec_if_count = 0;
+ zrouter.rtadv.adv_if_count = 0;
+ zrouter.rtadv.adv_msec_if_count = 0;
}
void rtadv_cmd_init(void)
}
#else
-void rtadv_init(struct zebra_vrf *zvrf)
+void rtadv_init(struct zebra_ns *zns)
{
/* Empty.*/;
}
-void rtadv_terminate(struct zebra_vrf *zvrf)
+void rtadv_terminate(struct zebra_ns *zns)
{
/* Empty.*/;
}