Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion netlink/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ if DEBUG
AM_CFLAGS += -O0 -DCLIB_DEBUG
vpp_build = vpp_debug-native
else
AM_CFLAGS += -O2
AM_CFLAGS += -O2 -DCLIB_VEC64=0
vpp_build = vpp-native
endif

Expand Down
16 changes: 8 additions & 8 deletions netlink/librtnl/mapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
* limitations under the License.
*/

#include <librtnl/mapper.h>
#include <librtnl/netns.h>
#include "mapper.h"
#include "netns.h"

#include <vnet/ip/ip.h>
#include <vnet/ip/lookup.h>
Expand Down Expand Up @@ -42,7 +42,7 @@ static mapper_main_t mapper_main;
mapper_map_t *mapper_get_by_ifindex(mapper_ns_t *ns, int ifindex)
{
mapper_map_t *map;
pool_foreach(map, ns->mappings, {
pool_foreach_old(map, ns->mappings, {
if (ifindex == map->linux_ifindex)
return map;
});
Expand Down Expand Up @@ -127,7 +127,7 @@ mapper_delmap(mapper_ns_t*ns, mapper_map_t *map)
{
ns_route_t *route;
netns_t *netns = netns_getns(ns->netns_handle);
pool_foreach(route, netns->routes, {
pool_foreach_old(route, netns->routes, {
if (route->oif == map->linux_ifindex)
mapper_add_del_route(ns, route, 1);
});
Expand All @@ -139,7 +139,7 @@ mapper_getmap(mapper_ns_t*ns, u32 sw_if_index,
int linux_ifindex, int create)
{
mapper_map_t *map;
pool_foreach(map, ns->mappings, {
pool_foreach_old(map, ns->mappings, {
if (linux_ifindex == map->linux_ifindex) {
if (sw_if_index != map->sw_if_index)
return NULL; //Cannot have multiple mapping with the same ifindex
Expand All @@ -160,7 +160,7 @@ mapper_getmap(mapper_ns_t*ns, u32 sw_if_index,
//Load available routes
ns_route_t *route;
netns_t *netns = netns_getns(ns->netns_handle);
pool_foreach(route, netns->routes, {
pool_foreach_old(route, netns->routes, {
if (route->oif == map->linux_ifindex)
mapper_add_del_route(ns, route, 0);
});
Expand All @@ -172,7 +172,7 @@ mapper_get_ns(char *nsname)
{
mapper_main_t *mm = &mapper_main;
mapper_ns_t *ns;
pool_foreach(ns, mm->namespaces, {
pool_foreach_old(ns, mm->namespaces, {
if (!strcmp(nsname, ns->nsname))
return ns - mm->namespaces;
});
Expand Down Expand Up @@ -246,7 +246,7 @@ mapper_del_ns(u32 nsindex)

//Remove all existing mappings
int i, *indexes = 0;
pool_foreach_index(i, ns->mappings, {
pool_foreach_index_old(i, ns->mappings, {
vec_add1(indexes, i);
});
vec_foreach_index(i, indexes) {
Expand Down
2 changes: 1 addition & 1 deletion netlink/librtnl/mapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#ifndef MAPPER_H_
#define MAPPER_H_

#include <librtnl/netns.h>
#include "netns.h"

/*
* Automatically map linux network routes to VPP.
Expand Down
18 changes: 9 additions & 9 deletions netlink/librtnl/netns.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* limitations under the License.
*/

#include <librtnl/netns.h>
#include "netns.h"

#include <vnet/ip/format.h>
#include <vnet/ethernet/ethernet.h>
Expand Down Expand Up @@ -315,7 +315,7 @@ netns_notify(netns_p *ns, void *obj, netns_type_t type, u32 flags)
{
netns_main_t *nm = &netns_main;
netns_handle_t *h;
pool_foreach(h, nm->handles, {
pool_foreach_old(h, nm->handles, {
if (h->netns_index == (ns - nm->netnss) && h->notify)
h->notify(obj, type, flags, h->opaque);
});
Expand All @@ -338,7 +338,7 @@ static ns_link_t *
ns_get_link(netns_p *ns, struct ifinfomsg *ifi, struct rtattr *rtas[])
{
ns_link_t *link;
pool_foreach(link, ns->netns.links, {
pool_foreach_old(link, ns->netns.links, {
if(ifi->ifi_index == link->ifi.ifi_index)
return link;
});
Expand Down Expand Up @@ -404,7 +404,7 @@ ns_get_route(netns_p *ns, struct rtmsg *rtm, struct rtattr *rtas[])
.rtm_type = 0xff
};

pool_foreach(route, ns->netns.routes, {
pool_foreach_old(route, ns->netns.routes, {
if(mask_match(&route->rtm, rtm, &msg, sizeof(struct rtmsg)) &&
rtnl_entry_match(route, rtas, ns_routemap))
return route;
Expand Down Expand Up @@ -467,7 +467,7 @@ ns_get_addr(netns_p *ns, struct ifaddrmsg *ifaddr, struct rtattr *rtas[])
.ifa_prefixlen = 0xff,
};

pool_foreach(addr, ns->netns.addresses, {
pool_foreach_old(addr, ns->netns.addresses, {
if(mask_match(&addr->ifaddr, ifaddr, &msg, sizeof(struct ifaddrmsg)) &&
rtnl_entry_match(addr, rtas, ns_addrmap))
return addr;
Expand Down Expand Up @@ -530,7 +530,7 @@ ns_get_neigh(netns_p *ns, struct ndmsg *nd, struct rtattr *rtas[])
.ndm_ifindex = 0xff,
};

pool_foreach(neigh, ns->netns.neighbors, {
pool_foreach_old(neigh, ns->netns.neighbors, {
if(mask_match(&neigh->nd, nd, &msg, sizeof(&msg)) &&
rtnl_entry_match(neigh, rtas, ns_neighmap))
return neigh;
Expand Down Expand Up @@ -597,7 +597,7 @@ ns_recv_error(rtnl_error_t err, uword o)
u32 *i = 0;

#define _(pool, type) \
pool_foreach_index(*i, ns->netns.pool, { \
pool_foreach_index_old(*i, ns->netns.pool, { \
vec_add1(indexes, *i); \
}) \
vec_foreach(i, indexes) { \
Expand Down Expand Up @@ -656,7 +656,7 @@ netns_get(char *name)
{
netns_main_t *nm = &netns_main;
netns_p *ns;
pool_foreach(ns, nm->netnss, {
pool_foreach_old(ns, nm->netnss, {
if (!strcmp(name, ns->netns.name))
return ns;
});
Expand Down Expand Up @@ -733,7 +733,7 @@ void netns_callme(u32 handle, char del)
return;

#define _(pool, type) \
pool_foreach_index(i, ns->netns.pool, { \
pool_foreach_index_old(i, ns->netns.pool, { \
h->notify(&ns->netns.pool[i], type, \
del?NETNS_F_DEL:NETNS_F_ADD, h->opaque); \
});
Expand Down
2 changes: 1 addition & 1 deletion netlink/librtnl/netns.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include <linux/netlink.h>
#include <net/if.h>

#include <librtnl/rtnl.h>
#include "rtnl.h"

/*include it for 'struct mpls_label'*/
#include <linux/mpls.h>
Expand Down
10 changes: 5 additions & 5 deletions netlink/librtnl/rtnl.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
#define _GNU_SOURCE
#include <sched.h>

#include <librtnl/rtnl.h>
#include <librtnl/netns.h>
#include "rtnl.h"
#include "netns.h"

#include <vlib/vlib.h>
#include <vlib/unix/unix.h>
Expand Down Expand Up @@ -266,7 +266,7 @@ static int rtnl_socket_open(rtnl_ns_t *ns)
.nl_groups = grpmask(RTNLGRP_LINK)| grpmask(RTNLGRP_IPV6_IFADDR) |
grpmask(RTNLGRP_IPV4_IFADDR) | grpmask(RTNLGRP_IPV4_ROUTE) |
grpmask(RTNLGRP_IPV6_ROUTE) | grpmask(RTNLGRP_NEIGH) |
grpmask(RTNLGRP_NOTIFY) | grpmask(RTNLGRP_MPLS_ROUTE),
grpmask(RTNLGRP_NOTIFY),
};

if (bind(ns->rtnl_socket, (struct sockaddr*) &addr, sizeof(addr))) {
Expand Down Expand Up @@ -516,7 +516,7 @@ rtnl_process (vlib_main_t * vm,
rm->now = vlib_time_now(vm);

if (event_type == ~0) { //Clock event or no event
pool_foreach(ns, rm->streams, {
pool_foreach_old(ns, rm->streams, {
if (ns->timeout < rm->now) {
ns->timeout = DBL_MAX;
rtnl_process_timeout(ns);
Expand Down Expand Up @@ -545,7 +545,7 @@ rtnl_process (vlib_main_t * vm,
vec_reset_length (event_data);

timeout = DBL_MAX;
pool_foreach(ns, rm->streams, {
pool_foreach_old(ns, rm->streams, {
if (ns->timeout < timeout)
timeout = ns->timeout;
});
Expand Down
30 changes: 30 additions & 0 deletions router/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Copyright (c) 2018 Cisco and/or its affiliates.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at:
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

add_vpp_plugin(router
SOURCES
librtnl/mapper.c
librtnl/netns.c
librtnl/rtnl.c
router/tap_inject.c
router/tap_inject_netlink.c
router/tap_inject_node.c
router/tap_inject_tap.c

INSTALL_HEADERS
librtnl/mapper.h
librtnl/netns.h
librtnl/rtnl.h
router/tap_inject.h

)
4 changes: 2 additions & 2 deletions router/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
AUTOMAKE_OPTIONS = foreign subdir-objects

AM_CFLAGS = -Wall -I@TOOLKIT_INCLUDE@
AM_CFLAGS = -Wall -I@TOOLKIT_INCLUDE@ -DCLIB_DEBUG -DCLIB_VEC64=0 -I../../vpp/build-root/build-vpp-native/vpp -I../../vpp/src -I../netlink

lib_LTLIBRARIES = router.la
router_la_SOURCES = \
Expand All @@ -13,7 +13,7 @@ nobase_include_HEADERS = \
router/tap_inject.h

router_la_LDFLAGS = -module
router_la_LIBADD = -lrtnl
router_la_LIBADD = -L../../vpp/build-root/build-vpp-native/vpp/lib/ -lrtnl

if WITH_PLUGIN_TOOLKIT
install-data-hook:
Expand Down
2 changes: 1 addition & 1 deletion router/router/tap_inject.c
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ tap_inject_enable_disable_all_interfaces (int enable)
/* Collect all the interface indices. */
interfaces = vnet_main->interface_main.hw_interfaces;
indices = enable ? &im->interfaces_to_enable : &im->interfaces_to_disable;
pool_foreach (hw, interfaces, vec_add1 (*indices, hw - interfaces));
pool_foreach_old (hw, interfaces, vec_add1 (*indices, hw - interfaces));

if (tap_inject_iface_isr (vlib_get_main (), 0, 0))
return clib_error_return (0, "tap-inject interface add del isr failed");
Expand Down
14 changes: 9 additions & 5 deletions router/router/tap_inject_netlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
* limitations under the License.
*/

#include <librtnl/netns.h>
#include <router/librtnl/netns.h>
#include <vlibmemory/api.h>
#include <vnet/ip/ip6_neighbor.h>
#include <vnet/ip-neighbor/ip6_neighbor.h>
#include <vnet/ip/lookup.h>
#include <vnet/fib/fib.h>
#include <vnet/ethernet/arp.h>
#include <vnet/arp/arp.h>
#include <arpa/inet.h>
#include <linux/mpls.h>
#include <vnet/mpls/packet.h>
Expand Down Expand Up @@ -95,6 +95,7 @@ add_del_link (ns_link_t * l, int is_del)
static void
add_del_neigh (ns_neigh_t * n, int is_del)
{
#if TBD
vnet_main_t * vnet_main = vnet_get_main ();
vlib_main_t * vm = vlib_get_main ();
u32 sw_if_index;
Expand All @@ -111,10 +112,9 @@ add_del_neigh (ns_neigh_t * n, int is_del)

memset (&a, 0, sizeof (a));

clib_memcpy (&a.ethernet, n->lladdr, ETHER_ADDR_LEN);
clib_memcpy (&a.mac, n->lladdr, ETHER_ADDR_LEN);
clib_memcpy (&a.ip4, n->dst, sizeof (a.ip4));


if (n->nd.ndm_state & NUD_REACHABLE)
{
vnet_arp_set_ip4_over_ethernet (vnet_main, sw_if_index,
Expand All @@ -126,6 +126,7 @@ add_del_neigh (ns_neigh_t * n, int is_del)
{
vnet_arp_unset_ip4_over_ethernet (vnet_main, sw_if_index, &a);
}

}
else if (n->nd.ndm_family == AF_INET6)
{
Expand All @@ -140,6 +141,7 @@ add_del_neigh (ns_neigh_t * n, int is_del)
vnet_unset_ip6_ethernet_neighbor (vm, sw_if_index,
(ip6_address_t *) n->dst);
}
#endif
}


Expand Down Expand Up @@ -225,6 +227,7 @@ add_del_route (ns_route_t * r, int is_del)
0 /* weight */, NULL,
FIB_ROUTE_PATH_FLAG_NONE);
}
#if 0
else if (r->rtm.rtm_family == AF_MPLS)
{
u32 dst_label;
Expand All @@ -250,6 +253,7 @@ add_del_route (ns_route_t * r, int is_del)
FIB_ENTRY_FLAG_NONE,
rpaths);
}
#endif
}


Expand Down
Loading