Skip to content

Commit

Permalink
bridge: show FDB lwt info
Browse files Browse the repository at this point in the history
Signed-off-by: David Lamparter <equinox@diac24.net>
  • Loading branch information
eqvinox committed Aug 18, 2017
1 parent 8616c2c commit f828804
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 4 deletions.
4 changes: 4 additions & 0 deletions bridge/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ ifeq ($(IP_CONFIG_SETNS),y)
CFLAGS += -DHAVE_SETNS
endif

ifeq ($(HAVE_ELF),y)
CFLAGS += -DHAVE_ELF
LDLIBS += -lelf
endif
ifeq ($(HAVE_MNL),y)
CFLAGS += -DHAVE_LIBMNL $(shell $(PKG_CONFIG) libmnl --cflags)
LDLIBS += $(shell $(PKG_CONFIG) libmnl --libs)
Expand Down
4 changes: 4 additions & 0 deletions bridge/fdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "br_common.h"
#include "rt_names.h"
#include "utils.h"
#include "lwtunnel.h"

static unsigned int filter_index, filter_vlan, filter_state;

Expand Down Expand Up @@ -204,6 +205,9 @@ int print_fdb(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
rta_getattr_u32(tb[NDA_VNI]));
}

if (tb[NDA_ENCAP_TYPE])
lwt_print_encap(fp, tb[NDA_ENCAP_TYPE], tb[NDA_ENCAP]);

if (tb[NDA_IFINDEX]) {
unsigned int ifindex = rta_getattr_u32(tb[NDA_IFINDEX]);

Expand Down
8 changes: 8 additions & 0 deletions include/linux/lwtunnel.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ enum lwtunnel_encap_types {
LWTUNNEL_ENCAP_SEG6,
LWTUNNEL_ENCAP_BPF,
LWTUNNEL_ENCAP_SEG6_LOCAL,
LWTUNNEL_ENCAP_PSEUDOWIRE,
__LWTUNNEL_ENCAP_MAX,
};

Expand Down Expand Up @@ -67,4 +68,11 @@ enum {

#define LWT_BPF_MAX_HEADROOM 256

enum {
LWT_PSEUDOWIRE_LOCAL_LABEL,
__LWT_PSEUDOWIRE_MAX,
};

#define LWT_PSEUDOWIRE_MAX (__LWT_PSEUDOWIRE_MAX - 1)

#endif /* _LWTUNNEL_H_ */
2 changes: 2 additions & 0 deletions include/linux/neighbour.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ enum {
NDA_MASTER,
NDA_LINK_NETNSID,
NDA_SRC_VNI,
NDA_ENCAP_TYPE,
NDA_ENCAP,
__NDA_MAX
};

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion ip/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ IPOBJ=ip.o ipaddress.o ipaddrlabel.o iproute.o iprule.o ipnetns.o \
iplink_vxlan.o tcp_metrics.o iplink_ipoib.o ipnetconf.o link_ip6tnl.o \
link_iptnl.o link_gre6.o iplink_bond.o iplink_bond_slave.o iplink_hsr.o \
iplink_bridge.o iplink_bridge_slave.o ipfou.o iplink_ipvlan.o \
iplink_geneve.o iplink_vrf.o iproute_lwtunnel.o ipmacsec.o ipila.o \
iplink_geneve.o iplink_vrf.o ipmacsec.o ipila.o \
ipvrf.o iplink_xstats.o ipseg6.o

RTMONOBJ=rtmon.o
Expand Down
2 changes: 1 addition & 1 deletion ip/iproute.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#include "rt_names.h"
#include "utils.h"
#include "ip_common.h"
#include "iproute_lwtunnel.h"
#include "lwtunnel.h"

#ifndef RTAX_RTTVAR
#define RTAX_RTTVAR RTAX_HOPS
Expand Down
3 changes: 2 additions & 1 deletion lib/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ CFLAGS += -fPIC

UTILOBJ = utils.o rt_names.o ll_types.o ll_proto.o ll_addr.o \
inet_proto.o namespace.o json_writer.o \
names.o color.o bpf.o exec.o fs.o
names.o color.o bpf.o exec.o fs.o \
lwtunnel.o

NLOBJ=libgenl.o ll_map.o libnetlink.o

Expand Down
18 changes: 17 additions & 1 deletion ip/iproute_lwtunnel.c → lib/lwtunnel.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

#include "rt_names.h"
#include "utils.h"
#include "iproute_lwtunnel.h"
#include "lwtunnel.h"
#include "bpf_util.h"

#include <linux/seg6.h>
Expand All @@ -45,6 +45,8 @@ static const char *format_encap_type(int type)
return "bpf";
case LWTUNNEL_ENCAP_SEG6:
return "seg6";
case LWTUNNEL_ENCAP_PSEUDOWIRE:
return "pseudowire";
default:
return "unknown";
}
Expand Down Expand Up @@ -256,6 +258,17 @@ static void print_encap_bpf(FILE *fp, struct rtattr *encap)
fprintf(fp, "%d ", rta_getattr_u32(tb[LWT_BPF_XMIT_HEADROOM]));
}

static void print_encap_pseudowire(FILE *fp, struct rtattr *encap)
{
struct rtattr *tb[LWT_PSEUDOWIRE_MAX+1];

parse_rtattr_nested(tb, LWT_PSEUDOWIRE_MAX, encap);

if (tb[LWT_PSEUDOWIRE_LOCAL_LABEL])
fprintf(fp, "local %u ",
rta_getattr_u32(tb[LWT_PSEUDOWIRE_LOCAL_LABEL]));
}

void lwt_print_encap(FILE *fp, struct rtattr *encap_type,
struct rtattr *encap)
{
Expand Down Expand Up @@ -287,6 +300,9 @@ void lwt_print_encap(FILE *fp, struct rtattr *encap_type,
case LWTUNNEL_ENCAP_SEG6:
print_encap_seg6(fp, encap);
break;
case LWTUNNEL_ENCAP_PSEUDOWIRE:
print_encap_pseudowire(fp, encap);
break;
}
}

Expand Down

0 comments on commit f828804

Please sign in to comment.