* [PATCH net-next 00/14] sctp: remove typedefs from structures part 6
From: Xin Long @ 2017-08-11 2:23 UTC (permalink / raw)
To: network dev, linux-sctp; +Cc: Marcelo Ricardo Leitner, Neil Horman, davem
As we know, typedef is suggested not to use in kernel, even checkpatch.pl
also gives warnings about it. Now sctp is using it for many structures.
All this kind of typedef's using should be removed. This patchset is the
part 6 to remove all typedefs in include/net/sctp/structs.h, command.h
and sm.h.
Just as the part 1-5, No any code's logic would be changed in these patches,
only cleaning up.
Note that this is the last part for this typedef cleaning up. after this
patchset, no more inappropriate typedefs in sctp. It's also to tidy some
codes when removing them, like fixing many indents, reodering some local
params, especially in the last 2 patches.
Xin Long (14):
sctp: remove the unused typedef sctp_packet_phandler_t
sctp: remove the typedef sctp_sender_hb_info_t
sctp: remove the typedef sctp_endpoint_type_t
sctp: remove the typedef sctp_cmsgs_t
sctp: remove the typedef sctp_dbg_objcnt_entry_t
sctp: remove the typedef sctp_socket_type_t
sctp: remove the typedef sctp_cmd_t
sctp: remove the typedef sctp_cmd_seq_t
sctp: remove the typedef sctp_arg_t
sctp: remove the typedef sctp_verb_t
sctp: remove the unused typedef sctp_sm_command_t
sctp: remove the typedef sctp_sm_table_entry_t
sctp: remove the typedef sctp_disposition_t
sctp: fix some indents in sm_make_chunk.c
include/net/sctp/command.h | 58 +-
include/net/sctp/sctp.h | 3 +-
include/net/sctp/sm.h | 188 +++---
include/net/sctp/structs.h | 26 +-
net/sctp/objcnt.c | 2 +-
net/sctp/probe.c | 13 +-
net/sctp/sm_make_chunk.c | 354 ++++++------
net/sctp/sm_sideeffect.c | 106 ++--
net/sctp/sm_statefuns.c | 1368 +++++++++++++++++++++++---------------------
net/sctp/sm_statetable.c | 42 +-
net/sctp/socket.c | 16 +-
11 files changed, 1104 insertions(+), 1072 deletions(-)
--
2.1.0
^ permalink raw reply
* [PATCH iproute2 net-next] config: put CFLAGS/LDLIBS in config.mk
From: Stephen Hemminger @ 2017-08-11 0:10 UTC (permalink / raw)
To: netdev; +Cc: Stephen Hemminger
This renames Config to config.mk and includes more Make input.
Now configure generates all the required CFLAGS and LDLIBS for
the optional libraries.
Also, use pkg-config to test for libelf, rather than using a test
program. This makes it consistent with other libraries.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
.gitignore | 1 -
Makefile | 8 +++---
README | 5 ++--
bridge/Makefile | 11 +-------
configure | 81 ++++++++++++++++++++++++++++----------------------------
devlink/Makefile | 3 ++-
genl/Makefile | 7 +----
ip/Makefile | 15 +----------
lib/Makefile | 14 +---------
misc/Makefile | 16 +----------
netem/Makefile | 7 +----
tc/Makefile | 15 +----------
tipc/Makefile | 5 ++--
13 files changed, 59 insertions(+), 129 deletions(-)
diff --git a/.gitignore b/.gitignore
index c3b8d386450b..308aec6ba80b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,6 +1,5 @@
static-syms.h
config.*
-Config
*.o
*.a
*.so
diff --git a/Makefile b/Makefile
index 1f88f7f56691..b0ea6794285c 100644
--- a/Makefile
+++ b/Makefile
@@ -54,12 +54,12 @@ SUBDIRS=lib ip tc bridge misc netem genl tipc devlink man
LIBNETLINK=../lib/libnetlink.a ../lib/libutil.a
LDLIBS += $(LIBNETLINK)
-all: Config
+all: config.mk
@set -e; \
for i in $(SUBDIRS); \
do echo; echo $$i; $(MAKE) $(MFLAGS) -C $$i; done
-Config:
+config.mk:
sh configure $(KERNEL_INCLUDE)
install: all
@@ -88,9 +88,9 @@ clean:
do $(MAKE) $(MFLAGS) -C $$i clean; done
clobber:
- touch Config
+ touch config.mk
$(MAKE) $(MFLAGS) clean
- rm -f Config cscope.*
+ rm -f config.mk cscope.*
distclean: clobber
diff --git a/README b/README
index c7a5118dd6d0..386fbaf6cf7d 100644
--- a/README
+++ b/README
@@ -21,8 +21,9 @@ database routines. Often this is in the db-devel package.
2. make
-The makefile will automatically build a Config file which
-contains whether or not ATM is available, etc.
+The makefile will automatically build a config.mk file which
+contains definitions of libraries that may or may not be available
+on the system such as: ATM, ELF, MNL, and SELINUX.
3. To make documentation, cd to doc/ directory , then
look at start of Makefile and set correct values for
diff --git a/bridge/Makefile b/bridge/Makefile
index fa448ea2e4fa..b2ae0a4ed04d 100644
--- a/bridge/Makefile
+++ b/bridge/Makefile
@@ -1,15 +1,6 @@
BROBJ = bridge.o fdb.o monitor.o link.o mdb.o vlan.o
-include ../Config
-
-ifeq ($(IP_CONFIG_SETNS),y)
- CFLAGS += -DHAVE_SETNS
-endif
-
-ifeq ($(HAVE_MNL),y)
- CFLAGS += -DHAVE_LIBMNL $(shell $(PKG_CONFIG) libmnl --cflags)
- LDLIBS += $(shell $(PKG_CONFIG) libmnl --libs)
-endif
+include ../config.mk
all: bridge
diff --git a/configure b/configure
index 88cbdb825689..7be8fb113cc9 100755
--- a/configure
+++ b/configure
@@ -3,6 +3,9 @@
#
INCLUDE=${1:-"$PWD/include"}
+# Output file which is input to Makefile
+CONFIG=config.mk
+
# Make a temp directory in build tree.
TMPDIR=$(mktemp -d config.XXXXXX)
trap 'status=$?; rm -rf $TMPDIR; exit $status' EXIT HUP INT QUIT TERM
@@ -10,7 +13,7 @@ trap 'status=$?; rm -rf $TMPDIR; exit $status' EXIT HUP INT QUIT TERM
check_prog()
{
echo -n "$2"
- command -v $1 >/dev/null 2>&1 && (echo "$3:=y" >> Config; echo "yes") || (echo "no"; return 1)
+ command -v $1 >/dev/null 2>&1 && (echo "$3:=y" >> $CONFIG; echo "yes") || (echo "no"; return 1)
}
check_docs()
@@ -30,9 +33,9 @@ check_toolchain()
: ${PKG_CONFIG:=pkg-config}
: ${AR=ar}
: ${CC=gcc}
- echo "PKG_CONFIG:=${PKG_CONFIG}" >>Config
- echo "AR:=${AR}" >>Config
- echo "CC:=${CC}" >>Config
+ echo "PKG_CONFIG:=${PKG_CONFIG}" >>$CONFIG
+ echo "AR:=${AR}" >>$CONFIG
+ echo "CC:=${CC}" >>$CONFIG
}
check_atm()
@@ -49,7 +52,7 @@ EOF
$CC -I$INCLUDE -o $TMPDIR/atmtest $TMPDIR/atmtest.c -latm >/dev/null 2>&1
if [ $? -eq 0 ]
then
- echo "TC_CONFIG_ATM:=y" >>Config
+ echo "TC_CONFIG_ATM:=y" >>$CONFIG
echo yes
else
echo no
@@ -61,7 +64,7 @@ check_xtables()
{
if ! ${PKG_CONFIG} xtables --exists
then
- echo "TC_CONFIG_NO_XT:=y" >>Config
+ echo "TC_CONFIG_NO_XT:=y" >>$CONFIG
fi
}
@@ -90,7 +93,7 @@ EOF
if $CC -I$INCLUDE $IPTC -o $TMPDIR/ipttest $TMPDIR/ipttest.c $IPTL \
$(${PKG_CONFIG} xtables --cflags --libs) -ldl >/dev/null 2>&1
then
- echo "TC_CONFIG_XT:=y" >>Config
+ echo "TC_CONFIG_XT:=y" >>$CONFIG
echo "using xtables"
fi
rm -f $TMPDIR/ipttest.c $TMPDIR/ipttest
@@ -99,7 +102,7 @@ EOF
check_xt_old()
{
# bail if previous XT checks has already succeded.
- if grep -q TC_CONFIG_XT Config
+ if grep -q TC_CONFIG_XT $CONFIG
then
return
fi
@@ -129,7 +132,7 @@ EOF
$CC -I$INCLUDE $IPTC -o $TMPDIR/ipttest $TMPDIR/ipttest.c $IPTL -ldl >/dev/null 2>&1
if [ $? -eq 0 ]
then
- echo "TC_CONFIG_XT_OLD:=y" >>Config
+ echo "TC_CONFIG_XT_OLD:=y" >>$CONFIG
echo "using old xtables (no need for xt-internal.h)"
fi
rm -f $TMPDIR/ipttest.c $TMPDIR/ipttest
@@ -138,7 +141,7 @@ EOF
check_xt_old_internal_h()
{
# bail if previous XT checks has already succeded.
- if grep -q TC_CONFIG_XT Config
+ if grep -q TC_CONFIG_XT $CONFIG
then
return
fi
@@ -170,14 +173,14 @@ EOF
if [ $? -eq 0 ]
then
echo "using old xtables with xt-internal.h"
- echo "TC_CONFIG_XT_OLD_H:=y" >>Config
+ echo "TC_CONFIG_XT_OLD_H:=y" >>$CONFIG
fi
rm -f $TMPDIR/ipttest.c $TMPDIR/ipttest
}
check_ipt()
{
- if ! grep TC_CONFIG_XT Config > /dev/null
+ if ! grep TC_CONFIG_XT $CONFIG > /dev/null
then
echo "using iptables"
fi
@@ -188,7 +191,7 @@ check_ipt_lib_dir()
IPT_LIB_DIR=$(${PKG_CONFIG} --variable=xtlibdir xtables)
if [ -n "$IPT_LIB_DIR" ]; then
echo $IPT_LIB_DIR
- echo "IPT_LIB_DIR:=$IPT_LIB_DIR" >> Config
+ echo "IPT_LIB_DIR:=$IPT_LIB_DIR" >> $CONFIG
return
fi
@@ -197,7 +200,7 @@ check_ipt_lib_dir()
for file in $dir/{xtables,iptables}/lib*t_*so ; do
if [ -f $file ]; then
echo ${file%/*}
- echo "IPT_LIB_DIR:=${file%/*}" >> Config
+ echo "IPT_LIB_DIR:=${file%/*}" >> $CONFIG
return
fi
done
@@ -218,8 +221,9 @@ EOF
$CC -I$INCLUDE -o $TMPDIR/setnstest $TMPDIR/setnstest.c >/dev/null 2>&1
if [ $? -eq 0 ]
then
- echo "IP_CONFIG_SETNS:=y" >>Config
+ echo "IP_CONFIG_SETNS:=y" >>$CONFIG
echo "yes"
+ echo "CFLAGS += -DHAVE_SETNS" >>$CONFIG
else
echo "no"
fi
@@ -249,7 +253,7 @@ EOF
if $CC -I$INCLUDE -o $TMPDIR/ipsettest $TMPDIR/ipsettest.c >/dev/null 2>&1
then
- echo "TC_CONFIG_IPSET:=y" >>Config
+ echo "TC_CONFIG_IPSET:=y" >>$CONFIG
echo "yes"
else
echo "no"
@@ -259,25 +263,16 @@ EOF
check_elf()
{
- cat >$TMPDIR/elftest.c <<EOF
-#include <libelf.h>
-#include <gelf.h>
-int main(void)
-{
- Elf_Scn *scn __attribute__((__unused__));
- GElf_Shdr shdr __attribute__((__unused__));;
- return elf_version(EV_CURRENT);
-}
-EOF
-
- if $CC -I$INCLUDE -o $TMPDIR/elftest $TMPDIR/elftest.c -lelf >/dev/null 2>&1
+ if ${PKG_CONFIG} libelf --exists
then
- echo "HAVE_ELF:=y" >>Config
+ echo "HAVE_ELF:=y" >>$CONFIG
echo "yes"
+
+ echo 'CFLAGS += -DHAVE_ELF' `${PKG_CONFIG} libelf --cflags` >> $CONFIG
+ echo 'LDLIBS += ' `${PKG_CONFIG} libelf --libs` >>$CONFIG
else
echo "no"
fi
- rm -f $TMPDIR/elftest.c $TMPDIR/elftest
}
check_selinux()
@@ -285,8 +280,11 @@ check_selinux()
{
if ${PKG_CONFIG} libselinux --exists
then
- echo "HAVE_SELINUX:=y" >>Config
+ echo "HAVE_SELINUX:=y" >>$CONFIG
echo "yes"
+
+ echo 'LDLIBS +=' `${PKG_CONFIG} --libs libselinux` >>$CONFIG
+ echo 'CFLAGS += -DHAVE_SELINUX' `${PKG_CONFIG} --cflags libselinux` >>$CONFIG
else
echo "no"
fi
@@ -296,8 +294,11 @@ check_mnl()
{
if ${PKG_CONFIG} libmnl --exists
then
- echo "HAVE_MNL:=y" >>Config
+ echo "HAVE_MNL:=y" >>$CONFIG
echo "yes"
+
+ echo 'CFLAGS += -DHAVE_LIBMNL' `${PKG_CONFIG} libmnl --cflags` >>$CONFIG
+ echo 'LDLIBS +=' `${PKG_CONFIG} libmnl --libs` >> $CONFIG
else
echo "no"
fi
@@ -317,7 +318,7 @@ EOF
$CC -I$INCLUDE -o $TMPDIR/dbtest $TMPDIR/dbtest.c -ldb >/dev/null 2>&1
if [ $? -eq 0 ]
then
- echo "HAVE_BERKELEY_DB:=y" >>Config
+ echo "HAVE_BERKELEY_DB:=y" >>$CONFIG
echo "yes"
else
echo "no"
@@ -351,8 +352,8 @@ endif
EOF
}
-echo "# Generated config based on" $INCLUDE >Config
-quiet_config >> Config
+echo "# Generated config based on" $INCLUDE >$CONFIG
+quiet_config >> $CONFIG
check_toolchain
@@ -362,7 +363,7 @@ echo -n " ATM "
check_atm
check_xtables
-if ! grep -q TC_CONFIG_NO_XT Config
+if ! grep -q TC_CONFIG_NO_XT $CONFIG
then
echo -n " IPT "
check_xt
@@ -375,7 +376,7 @@ then
fi
echo
-if ! grep -q TC_CONFIG_NO_XT Config
+if ! grep -q TC_CONFIG_NO_XT $CONFIG
then
echo -n "iptables modules directory: "
check_ipt_lib_dir
@@ -401,6 +402,6 @@ echo -n "docs:"
check_docs
echo
-echo >> Config
-echo "%.o: %.c" >> Config
-echo ' $(QUIET_CC)$(CC) $(CFLAGS) $(EXTRA_CFLAGS) -c -o $@ $<' >> Config
+echo >> $CONFIG
+echo "%.o: %.c" >> $CONFIG
+echo ' $(QUIET_CC)$(CC) $(CFLAGS) $(EXTRA_CFLAGS) -c -o $@ $<' >> $CONFIG
diff --git a/devlink/Makefile b/devlink/Makefile
index 7256c28708eb..3b2067d6658c 100644
--- a/devlink/Makefile
+++ b/devlink/Makefile
@@ -1,4 +1,5 @@
-include ../Config
+include ../config.mk
+
ifeq ($(HAVE_MNL),y)
DEVLINKOBJ = devlink.o mnlg.o
diff --git a/genl/Makefile b/genl/Makefile
index f0efe1ac6647..de1635e498ad 100644
--- a/genl/Makefile
+++ b/genl/Makefile
@@ -1,6 +1,6 @@
GENLOBJ=genl.o
-include ../Config
+include ../config.mk
SHARED_LIBS ?= y
CFLAGS += -fno-strict-aliasing
@@ -17,11 +17,6 @@ LDFLAGS += -Wl,-export-dynamic
LDLIBS += -lm -ldl
endif
-ifeq ($(HAVE_MNL),y)
- CFLAGS += -DHAVE_LIBMNL $(shell $(PKG_CONFIG) libmnl --cflags)
- LDLIBS += $(shell $(PKG_CONFIG) libmnl --libs)
-endif
-
all: genl
genl: $(GENLOBJ) $(LIBNETLINK) $(LIBUTIL) $(GENLLIB)
diff --git a/ip/Makefile b/ip/Makefile
index a754c04d2dbb..5a1c7ad2d264 100644
--- a/ip/Makefile
+++ b/ip/Makefile
@@ -13,20 +13,7 @@ IPOBJ=ip.o ipaddress.o ipaddrlabel.o iproute.o iprule.o ipnetns.o \
RTMONOBJ=rtmon.o
-include ../Config
-
-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)
-endif
+include ../config.mk
ALLOBJ=$(IPOBJ) $(RTMONOBJ)
SCRIPTS=ifcfg rtpr routel routef
diff --git a/lib/Makefile b/lib/Makefile
index b7b1d5685b94..5e9f72facd36 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -1,16 +1,4 @@
-include ../Config
-
-ifeq ($(IP_CONFIG_SETNS),y)
- CFLAGS += -DHAVE_SETNS
-endif
-
-ifeq ($(HAVE_ELF),y)
- CFLAGS += -DHAVE_ELF
-endif
-
-ifeq ($(HAVE_MNL),y)
- CFLAGS += -DHAVE_LIBMNL $(shell $(PKG_CONFIG) libmnl --cflags)
-endif
+include ../config.mk
CFLAGS += -fPIC
diff --git a/misc/Makefile b/misc/Makefile
index fa90308e4848..d02616e3482a 100644
--- a/misc/Makefile
+++ b/misc/Makefile
@@ -3,26 +3,12 @@ LNSTATOBJ=lnstat.o lnstat_util.o
TARGETS=ss nstat ifstat rtacct lnstat
-include ../Config
+include ../config.mk
ifeq ($(HAVE_BERKELEY_DB),y)
TARGETS += arpd
endif
-ifeq ($(HAVE_SELINUX),y)
- LDLIBS += $(shell $(PKG_CONFIG) --libs libselinux)
- CFLAGS += $(shell $(PKG_CONFIG) --cflags libselinux) -DHAVE_SELINUX
-endif
-
-ifeq ($(IP_CONFIG_SETNS),y)
- CFLAGS += -DHAVE_SETNS
-endif
-
-ifeq ($(HAVE_MNL),y)
- CFLAGS += -DHAVE_LIBMNL $(shell $(PKG_CONFIG) libmnl --cflags)
- LDLIBS += $(shell $(PKG_CONFIG) libmnl --libs)
-endif
-
all: $(TARGETS)
ss: $(SSOBJ)
diff --git a/netem/Makefile b/netem/Makefile
index 2499f086f24d..434185273f64 100644
--- a/netem/Makefile
+++ b/netem/Makefile
@@ -1,4 +1,4 @@
-include ../Config
+include ../config.mk
DISTGEN = maketable normal pareto paretonormal
DISTDATA = normal.dist pareto.dist paretonormal.dist experimental.dist
@@ -7,11 +7,6 @@ HOSTCC ?= $(CC)
CCOPTS = $(CBUILD_CFLAGS)
LDLIBS += -lm
-ifeq ($(HAVE_MNL),y)
- CFLAGS += -DHAVE_LIBMNL $(shell $(PKG_CONFIG) libmnl --cflags)
- LDLIBS += $(shell $(PKG_CONFIG) libmnl --libs)
-endif
-
all: $(DISTGEN) $(DISTDATA)
$(DISTGEN):
diff --git a/tc/Makefile b/tc/Makefile
index a9b4b8e60dac..777de5e6da76 100644
--- a/tc/Makefile
+++ b/tc/Makefile
@@ -2,11 +2,7 @@ TCOBJ= tc.o tc_qdisc.o tc_class.o tc_filter.o tc_util.o tc_monitor.o \
tc_exec.o m_police.o m_estimator.o m_action.o m_ematch.o \
emp_ematch.yacc.o emp_ematch.lex.o
-include ../Config
-
-ifeq ($(IP_CONFIG_SETNS),y)
- CFLAGS += -DHAVE_SETNS
-endif
+include ../config.mk
SHARED_LIBS ?= y
@@ -102,15 +98,6 @@ endif
TCOBJ += $(TCMODULES)
LDLIBS += -L. -lm
-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)
-endif
-
ifeq ($(SHARED_LIBS),y)
LDLIBS += -ldl
LDFLAGS += -Wl,-export-dynamic
diff --git a/tipc/Makefile b/tipc/Makefile
index 87e3cac3756f..2212beb06534 100644
--- a/tipc/Makefile
+++ b/tipc/Makefile
@@ -1,4 +1,5 @@
-include ../Config
+include ../config.mk
+
ifeq ($(HAVE_MNL),y)
TIPCOBJ=bearer.o \
@@ -8,8 +9,6 @@ TIPCOBJ=bearer.o \
node.o socket.o \
peer.o tipc.o
-include ../Config
-
TARGETS=tipc
CFLAGS += $(shell $(PKG_CONFIG) libmnl --cflags)
LDLIBS += $(shell $(PKG_CONFIG) libmnl --libs)
--
2.11.0
^ permalink raw reply related
* [PATCH] selftests: bpf: add check for ip XDP redirect
From: William Tu @ 2017-08-11 0:02 UTC (permalink / raw)
To: netdev; +Cc: Daniel Borkmann, John Fastabend
Kernel test robot reports error when running test_xdp_redirect.sh.
Check if ip tool supports xdpgeneric, if not, skip the test.
Signed-off-by: William Tu <u9012063@gmail.com>
Cc: Daniel Borkmann <daniel@iogearbox.net>
Cc: John Fastabend <john.fastabend@gmail.com>
---
tools/testing/selftests/bpf/test_xdp_redirect.sh | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/tools/testing/selftests/bpf/test_xdp_redirect.sh b/tools/testing/selftests/bpf/test_xdp_redirect.sh
index d8c73ed6e040..c5a8b7173c12 100755
--- a/tools/testing/selftests/bpf/test_xdp_redirect.sh
+++ b/tools/testing/selftests/bpf/test_xdp_redirect.sh
@@ -23,6 +23,11 @@ cleanup()
ip netns del ns2 2> /dev/null
}
+ip link set dev lo xdpgeneric off 2>/dev/null > /dev/null
+if [ $? -ne 0 ];then
+ echo "selftests: [SKIP] Could not run test without the ip xdpgeneric support"
+ exit 0
+fi
set -e
ip netns add ns1
--
2.7.4
^ permalink raw reply related
* Re: [PATCH iproute2 master] bpf: unbreak libelf linkage for bpf obj loader
From: Stephen Hemminger @ 2017-08-10 23:41 UTC (permalink / raw)
To: Daniel Borkmann; +Cc: netdev
In-Reply-To: <598C1CDD.3090604@iogearbox.net>
On Thu, 10 Aug 2017 10:44:13 +0200
Daniel Borkmann <daniel@iogearbox.net> wrote:
> On 08/10/2017 02:35 AM, Stephen Hemminger wrote:
> > On Thu, 10 Aug 2017 00:15:41 +0200
> > Daniel Borkmann <daniel@iogearbox.net> wrote:
> >
> >> Commit 69fed534a533 ("change how Config is used in Makefile's") moved
> >> HAVE_MNL specific CFLAGS/LDLIBS for building with libmnl out of the
> >> top level Makefile into sub-Makefiles. However, it also removed the
> >> HAVE_ELF specific CFLAGS/LDLIBS entirely, which breaks the BPF object
> >> loader for tc and ip with "No ELF library support compiled in." despite
> >> having libelf detected in configure script. Fix it similarly as in
> >> 69fed534a533 for HAVE_ELF.
> >>
> >> Fixes: 69fed534a533 ("change how Config is used in Makefile's")
> >> Reported-by: Jeffrey Panneman <jeffrey.panneman@tno.nl>
> >> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
> >
> > Thanks, but I am thinking maybe a better solution long term would be to
> > move all the package specific stuff into the generated Config file.
> >
> > That way only the generation shell script would have to change.
> >
> > Also, all the flags should probably be using pkg-config to get the values.
>
> Sure, sounds all good, for the time being, I would like to have
> that breakage undone though, so users can work with loading BPF
> programs again on -master.
>
> Thanks,
> Daniel
Agree. I will merge this for master, and work on better config management
in net-next.
^ permalink raw reply
* Re: [PATCH] MAINTAINERS: update the NetLabel and Labeled Networking information
From: James Morris @ 2017-08-10 23:25 UTC (permalink / raw)
To: Paul Moore; +Cc: netdev, linux-security-module, selinux
In-Reply-To: <CAHC9VhSk1veoZJvHjVnSy6ztyDdoHBQOVWMyXb8X4Db+-xXENw@mail.gmail.com>
On Thu, 10 Aug 2017, Paul Moore wrote:
> On Thu, Aug 10, 2017 at 3:13 PM, Paul Moore <pmoore@redhat.com> wrote:
> > From: Paul Moore <paul@paul-moore.com>
> >
> > Signed-off-by: Paul Moore <paul@paul-moore.com>
> > ---
> > MAINTAINERS | 24 ++++++++++++++----------
> > 1 file changed, 14 insertions(+), 10 deletions(-)
>
> I'm planning on sending this up via the SELinux tree with some other
> MAINTAINERS updates, consider this more of a FYI posting.
Oops, already applied to -next.
>
> > diff --git a/MAINTAINERS b/MAINTAINERS
> > index 65990909fe73..be25ebaaeec3 100644
> > --- a/MAINTAINERS
> > +++ b/MAINTAINERS
> > @@ -9112,15 +9112,6 @@ F: net/*/netfilter/
> > F: net/netfilter/
> > F: net/bridge/br_netfilter*.c
> >
> > -NETLABEL
> > -M: Paul Moore <paul@paul-moore.com>
> > -W: http://netlabel.sf.net
> > -L: netdev@vger.kernel.org
> > -S: Maintained
> > -F: Documentation/netlabel/
> > -F: include/net/netlabel.h
> > -F: net/netlabel/
> > -
> > NETROM NETWORK LAYER
> > M: Ralf Baechle <ralf@linux-mips.org>
> > L: linux-hams@vger.kernel.org
> > @@ -9248,10 +9239,23 @@ F: net/ipv6/
> > F: include/net/ip*
> > F: arch/x86/net/*
> >
> > -NETWORKING [LABELED] (NetLabel, CIPSO, Labeled IPsec, SECMARK)
> > +NETWORKING [LABELED] (NetLabel, Labeled IPsec, SECMARK)
> > M: Paul Moore <paul@paul-moore.com>
> > +W: https://github.com/netlabel
> > L: netdev@vger.kernel.org
> > +L: linux-security-module@vger.kernel.org
> > S: Maintained
> > +F: Documentation/netlabel/
> > +F: include/net/calipso.h
> > +F: include/net/cipso_ipv4.h
> > +F: include/net/netlabel.h
> > +F: include/uapi/linux/netfilter/xt_SECMARK.h
> > +F: include/uapi/linux/netfilter/xt_CONNSECMARK.h
> > +F: net/netlabel/
> > +F: net/ipv4/cipso_ipv4.c
> > +F: net/ipv6/calipso.c
> > +F: net/netfilter/xt_CONNSECMARK.c
> > +F: net/netfilter/xt_SECMARK.c
> >
> > NETWORKING [TLS]
> > M: Ilya Lesokhin <ilyal@mellanox.com>
>
>
--
James Morris
<jmorris@namei.org>
^ permalink raw reply
* Re: [PATCH] MAINTAINERS: update the NetLabel and Labeled Networking information
From: James Morris @ 2017-08-10 23:24 UTC (permalink / raw)
To: Paul Moore; +Cc: linux-security-module, netdev, selinux
In-Reply-To: <150239239837.19177.4190318681371376062.stgit@sifl>
On Thu, 10 Aug 2017, Paul Moore wrote:
> From: Paul Moore <paul@paul-moore.com>
>
> Signed-off-by: Paul Moore <paul@paul-moore.com>
Applied to
git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security.git next
--
James Morris
<jmorris@namei.org>
^ permalink raw reply
* [PATCH v3 net-next 2/2] wan: dscc4: convert to plain DMA API
From: Alexey Khoroshilov @ 2017-08-10 22:55 UTC (permalink / raw)
To: Francois Romieu, David S. Miller
Cc: Alexey Khoroshilov, netdev, linux-kernel, ldv-project
In-Reply-To: <1502405721-27738-1-git-send-email-khoroshilov@ispras.ru>
Make use the dma_*() interfaces rather than the pci_*() interfaces.
Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
---
drivers/net/wan/dscc4.c | 96 ++++++++++++++++++++++++++-----------------------
1 file changed, 51 insertions(+), 45 deletions(-)
diff --git a/drivers/net/wan/dscc4.c b/drivers/net/wan/dscc4.c
index 8480dbf..a043fb1 100644
--- a/drivers/net/wan/dscc4.c
+++ b/drivers/net/wan/dscc4.c
@@ -483,20 +483,20 @@ static void dscc4_tx_print(struct net_device *dev,
static void dscc4_release_ring(struct dscc4_dev_priv *dpriv)
{
- struct pci_dev *pdev = dpriv->pci_priv->pdev;
+ struct device *d = &dpriv->pci_priv->pdev->dev;
struct TxFD *tx_fd = dpriv->tx_fd;
struct RxFD *rx_fd = dpriv->rx_fd;
struct sk_buff **skbuff;
int i;
- pci_free_consistent(pdev, TX_TOTAL_SIZE, tx_fd, dpriv->tx_fd_dma);
- pci_free_consistent(pdev, RX_TOTAL_SIZE, rx_fd, dpriv->rx_fd_dma);
+ dma_free_coherent(d, TX_TOTAL_SIZE, tx_fd, dpriv->tx_fd_dma);
+ dma_free_coherent(d, RX_TOTAL_SIZE, rx_fd, dpriv->rx_fd_dma);
skbuff = dpriv->tx_skbuff;
for (i = 0; i < TX_RING_SIZE; i++) {
if (*skbuff) {
- pci_unmap_single(pdev, le32_to_cpu(tx_fd->data),
- (*skbuff)->len, PCI_DMA_TODEVICE);
+ dma_unmap_single(d, le32_to_cpu(tx_fd->data),
+ (*skbuff)->len, DMA_TO_DEVICE);
dev_kfree_skb(*skbuff);
}
skbuff++;
@@ -506,8 +506,9 @@ static void dscc4_release_ring(struct dscc4_dev_priv *dpriv)
skbuff = dpriv->rx_skbuff;
for (i = 0; i < RX_RING_SIZE; i++) {
if (*skbuff) {
- pci_unmap_single(pdev, le32_to_cpu(rx_fd->data),
- RX_MAX(HDLC_MAX_MRU), PCI_DMA_FROMDEVICE);
+ dma_unmap_single(d, le32_to_cpu(rx_fd->data),
+ RX_MAX(HDLC_MAX_MRU),
+ DMA_FROM_DEVICE);
dev_kfree_skb(*skbuff);
}
skbuff++;
@@ -519,7 +520,7 @@ static inline int try_get_rx_skb(struct dscc4_dev_priv *dpriv,
struct net_device *dev)
{
unsigned int dirty = dpriv->rx_dirty%RX_RING_SIZE;
- struct pci_dev *pdev = dpriv->pci_priv->pdev;
+ struct device *d = &dpriv->pci_priv->pdev->dev;
struct RxFD *rx_fd = dpriv->rx_fd + dirty;
const int len = RX_MAX(HDLC_MAX_MRU);
struct sk_buff *skb;
@@ -530,8 +531,8 @@ static inline int try_get_rx_skb(struct dscc4_dev_priv *dpriv,
goto err_out;
skb->protocol = hdlc_type_trans(skb, dev);
- addr = pci_map_single(pdev, skb->data, len, PCI_DMA_FROMDEVICE);
- if (pci_dma_mapping_error(pdev, addr))
+ addr = dma_map_single(d, skb->data, len, DMA_FROM_DEVICE);
+ if (dma_mapping_error(d, addr))
goto err_free_skb;
dpriv->rx_skbuff[dirty] = skb;
@@ -654,7 +655,7 @@ static inline void dscc4_rx_skb(struct dscc4_dev_priv *dpriv,
struct net_device *dev)
{
struct RxFD *rx_fd = dpriv->rx_fd + dpriv->rx_current%RX_RING_SIZE;
- struct pci_dev *pdev = dpriv->pci_priv->pdev;
+ struct device *d = &dpriv->pci_priv->pdev->dev;
struct sk_buff *skb;
int pkt_len;
@@ -664,8 +665,8 @@ static inline void dscc4_rx_skb(struct dscc4_dev_priv *dpriv,
goto refill;
}
pkt_len = TO_SIZE(le32_to_cpu(rx_fd->state2));
- pci_unmap_single(pdev, le32_to_cpu(rx_fd->data),
- RX_MAX(HDLC_MAX_MRU), PCI_DMA_FROMDEVICE);
+ dma_unmap_single(d, le32_to_cpu(rx_fd->data),
+ RX_MAX(HDLC_MAX_MRU), DMA_FROM_DEVICE);
if ((skb->data[--pkt_len] & FrameOk) == FrameOk) {
dev->stats.rx_packets++;
dev->stats.rx_bytes += pkt_len;
@@ -782,8 +783,8 @@ static int dscc4_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
rc = -ENOMEM;
- priv->iqcfg = (__le32 *) pci_alloc_consistent(pdev,
- IRQ_RING_SIZE*sizeof(__le32), &priv->iqcfg_dma);
+ priv->iqcfg = (__le32 *)dma_alloc_coherent(&pdev->dev,
+ IRQ_RING_SIZE*sizeof(__le32), &priv->iqcfg_dma, GFP_KERNEL);
if (!priv->iqcfg)
goto err_free_irq_5;
writel(priv->iqcfg_dma, ioaddr + IQCFG);
@@ -794,16 +795,18 @@ static int dscc4_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
*/
for (i = 0; i < dev_per_card; i++) {
dpriv = priv->root + i;
- dpriv->iqtx = (__le32 *) pci_alloc_consistent(pdev,
- IRQ_RING_SIZE*sizeof(u32), &dpriv->iqtx_dma);
+ dpriv->iqtx = (__le32 *)dma_alloc_coherent(&pdev->dev,
+ IRQ_RING_SIZE*sizeof(u32), &dpriv->iqtx_dma,
+ GFP_KERNEL);
if (!dpriv->iqtx)
goto err_free_iqtx_6;
writel(dpriv->iqtx_dma, ioaddr + IQTX0 + i*4);
}
for (i = 0; i < dev_per_card; i++) {
dpriv = priv->root + i;
- dpriv->iqrx = (__le32 *) pci_alloc_consistent(pdev,
- IRQ_RING_SIZE*sizeof(u32), &dpriv->iqrx_dma);
+ dpriv->iqrx = (__le32 *)dma_alloc_coherent(&pdev->dev,
+ IRQ_RING_SIZE*sizeof(u32), &dpriv->iqrx_dma,
+ GFP_KERNEL);
if (!dpriv->iqrx)
goto err_free_iqrx_7;
writel(dpriv->iqrx_dma, ioaddr + IQRX0 + i*4);
@@ -827,18 +830,18 @@ static int dscc4_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
err_free_iqrx_7:
while (--i >= 0) {
dpriv = priv->root + i;
- pci_free_consistent(pdev, IRQ_RING_SIZE*sizeof(u32),
- dpriv->iqrx, dpriv->iqrx_dma);
+ dma_free_coherent(&pdev->dev, IRQ_RING_SIZE*sizeof(u32),
+ dpriv->iqrx, dpriv->iqrx_dma);
}
i = dev_per_card;
err_free_iqtx_6:
while (--i >= 0) {
dpriv = priv->root + i;
- pci_free_consistent(pdev, IRQ_RING_SIZE*sizeof(u32),
- dpriv->iqtx, dpriv->iqtx_dma);
+ dma_free_coherent(&pdev->dev, IRQ_RING_SIZE*sizeof(u32),
+ dpriv->iqtx, dpriv->iqtx_dma);
}
- pci_free_consistent(pdev, IRQ_RING_SIZE*sizeof(u32), priv->iqcfg,
- priv->iqcfg_dma);
+ dma_free_coherent(&pdev->dev, IRQ_RING_SIZE*sizeof(u32), priv->iqcfg,
+ priv->iqcfg_dma);
err_free_irq_5:
free_irq(pdev->irq, priv->root);
err_release_4:
@@ -1153,13 +1156,13 @@ static netdev_tx_t dscc4_start_xmit(struct sk_buff *skb,
struct net_device *dev)
{
struct dscc4_dev_priv *dpriv = dscc4_priv(dev);
- struct pci_dev *pdev = dpriv->pci_priv->pdev;
+ struct device *d = &dpriv->pci_priv->pdev->dev;
struct TxFD *tx_fd;
dma_addr_t addr;
int next;
- addr = pci_map_single(pdev, skb->data, skb->len, PCI_DMA_TODEVICE);
- if (pci_dma_mapping_error(pdev, addr)) {
+ addr = dma_map_single(d, skb->data, skb->len, DMA_TO_DEVICE);
+ if (dma_mapping_error(d, addr)) {
dev_kfree_skb_any(skb);
dev->stats.tx_dropped++;
return NETDEV_TX_OK;
@@ -1587,8 +1590,9 @@ static void dscc4_tx_irq(struct dscc4_pci_priv *ppriv,
tx_fd = dpriv->tx_fd + cur;
skb = dpriv->tx_skbuff[cur];
if (skb) {
- pci_unmap_single(ppriv->pdev, le32_to_cpu(tx_fd->data),
- skb->len, PCI_DMA_TODEVICE);
+ dma_unmap_single(&ppriv->pdev->dev,
+ le32_to_cpu(tx_fd->data),
+ skb->len, DMA_TO_DEVICE);
if (tx_fd->state & FrameEnd) {
dev->stats.tx_packets++;
dev->stats.tx_bytes += skb->len;
@@ -1902,7 +1906,7 @@ static struct sk_buff *dscc4_init_dummy_skb(struct dscc4_dev_priv *dpriv)
skb = dev_alloc_skb(DUMMY_SKB_SIZE);
if (skb) {
- struct pci_dev *pdev = dpriv->pci_priv->pdev;
+ struct device *d = &dpriv->pci_priv->pdev->dev;
int last = dpriv->tx_dirty%TX_RING_SIZE;
struct TxFD *tx_fd = dpriv->tx_fd + last;
dma_addr_t addr;
@@ -1910,9 +1914,9 @@ static struct sk_buff *dscc4_init_dummy_skb(struct dscc4_dev_priv *dpriv)
skb->len = DUMMY_SKB_SIZE;
skb_copy_to_linear_data(skb, version,
strlen(version) % DUMMY_SKB_SIZE);
- addr = pci_map_single(pdev, skb->data, DUMMY_SKB_SIZE,
- PCI_DMA_TODEVICE);
- if (pci_dma_mapping_error(pdev, addr)) {
+ addr = dma_map_single(d, skb->data, DUMMY_SKB_SIZE,
+ DMA_TO_DEVICE);
+ if (dma_mapping_error(d, addr)) {
dev_kfree_skb_any(skb);
return NULL;
}
@@ -1926,18 +1930,20 @@ static struct sk_buff *dscc4_init_dummy_skb(struct dscc4_dev_priv *dpriv)
static int dscc4_init_ring(struct net_device *dev)
{
struct dscc4_dev_priv *dpriv = dscc4_priv(dev);
- struct pci_dev *pdev = dpriv->pci_priv->pdev;
+ struct device *d = &dpriv->pci_priv->pdev->dev;
struct TxFD *tx_fd;
struct RxFD *rx_fd;
void *ring;
int i;
- ring = pci_alloc_consistent(pdev, RX_TOTAL_SIZE, &dpriv->rx_fd_dma);
+ ring = dma_alloc_coherent(d, RX_TOTAL_SIZE, &dpriv->rx_fd_dma,
+ GFP_KERNEL);
if (!ring)
goto err_out;
dpriv->rx_fd = rx_fd = (struct RxFD *) ring;
- ring = pci_alloc_consistent(pdev, TX_TOTAL_SIZE, &dpriv->tx_fd_dma);
+ ring = dma_alloc_coherent(d, TX_TOTAL_SIZE, &dpriv->tx_fd_dma,
+ GFP_KERNEL);
if (!ring)
goto err_free_dma_rx;
dpriv->tx_fd = tx_fd = (struct TxFD *) ring;
@@ -1975,9 +1981,9 @@ static int dscc4_init_ring(struct net_device *dev)
return 0;
err_free_dma_tx:
- pci_free_consistent(pdev, TX_TOTAL_SIZE, ring, dpriv->tx_fd_dma);
+ dma_free_coherent(d, TX_TOTAL_SIZE, ring, dpriv->tx_fd_dma);
err_free_dma_rx:
- pci_free_consistent(pdev, RX_TOTAL_SIZE, rx_fd, dpriv->rx_fd_dma);
+ dma_free_coherent(d, RX_TOTAL_SIZE, rx_fd, dpriv->rx_fd_dma);
err_out:
return -ENOMEM;
}
@@ -1997,16 +2003,16 @@ static void dscc4_remove_one(struct pci_dev *pdev)
dscc4_pci_reset(pdev, ioaddr);
free_irq(pdev->irq, root);
- pci_free_consistent(pdev, IRQ_RING_SIZE*sizeof(u32), ppriv->iqcfg,
- ppriv->iqcfg_dma);
+ dma_free_coherent(&pdev->dev, IRQ_RING_SIZE*sizeof(u32), ppriv->iqcfg,
+ ppriv->iqcfg_dma);
for (i = 0; i < dev_per_card; i++) {
struct dscc4_dev_priv *dpriv = root + i;
dscc4_release_ring(dpriv);
- pci_free_consistent(pdev, IRQ_RING_SIZE*sizeof(u32),
- dpriv->iqrx, dpriv->iqrx_dma);
- pci_free_consistent(pdev, IRQ_RING_SIZE*sizeof(u32),
- dpriv->iqtx, dpriv->iqtx_dma);
+ dma_free_coherent(&pdev->dev, IRQ_RING_SIZE*sizeof(u32),
+ dpriv->iqrx, dpriv->iqrx_dma);
+ dma_free_coherent(&pdev->dev, IRQ_RING_SIZE*sizeof(u32),
+ dpriv->iqtx, dpriv->iqtx_dma);
}
dscc4_free1(pdev);
--
2.7.4
^ permalink raw reply related
* [PATCH v3 net-next 1/2] wan: dscc4: add checks for dma mapping errors
From: Alexey Khoroshilov @ 2017-08-10 22:55 UTC (permalink / raw)
To: Francois Romieu, David S. Miller
Cc: Alexey Khoroshilov, netdev, linux-kernel, ldv-project
In-Reply-To: <20170808232147.GA27445@electric-eye.fr.zoreil.com>
The driver does not check if mapping dma memory succeed.
The patch adds the checks and failure handling.
Found by Linux Driver Verification project (linuxtesting.org).
Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
---
v2: Fix issues noted by David Miller and Francois Romieu.
v3: Improve code per Francois Romieu recommendations.
Convert to plain DMA API.
drivers/net/wan/dscc4.c | 53 ++++++++++++++++++++++++++++++++++---------------
1 file changed, 37 insertions(+), 16 deletions(-)
diff --git a/drivers/net/wan/dscc4.c b/drivers/net/wan/dscc4.c
index 799830f..8480dbf 100644
--- a/drivers/net/wan/dscc4.c
+++ b/drivers/net/wan/dscc4.c
@@ -519,22 +519,30 @@ static inline int try_get_rx_skb(struct dscc4_dev_priv *dpriv,
struct net_device *dev)
{
unsigned int dirty = dpriv->rx_dirty%RX_RING_SIZE;
+ struct pci_dev *pdev = dpriv->pci_priv->pdev;
struct RxFD *rx_fd = dpriv->rx_fd + dirty;
const int len = RX_MAX(HDLC_MAX_MRU);
struct sk_buff *skb;
- int ret = 0;
+ dma_addr_t addr;
skb = dev_alloc_skb(len);
+ if (!skb)
+ goto err_out;
+
+ skb->protocol = hdlc_type_trans(skb, dev);
+ addr = pci_map_single(pdev, skb->data, len, PCI_DMA_FROMDEVICE);
+ if (pci_dma_mapping_error(pdev, addr))
+ goto err_free_skb;
+
dpriv->rx_skbuff[dirty] = skb;
- if (skb) {
- skb->protocol = hdlc_type_trans(skb, dev);
- rx_fd->data = cpu_to_le32(pci_map_single(dpriv->pci_priv->pdev,
- skb->data, len, PCI_DMA_FROMDEVICE));
- } else {
- rx_fd->data = 0;
- ret = -1;
- }
- return ret;
+ rx_fd->data = cpu_to_le32(addr);
+ return 0;
+
+err_free_skb:
+ dev_kfree_skb_any(skb);
+err_out:
+ rx_fd->data = 0;
+ return -1;
}
/*
@@ -1145,16 +1153,23 @@ static netdev_tx_t dscc4_start_xmit(struct sk_buff *skb,
struct net_device *dev)
{
struct dscc4_dev_priv *dpriv = dscc4_priv(dev);
- struct dscc4_pci_priv *ppriv = dpriv->pci_priv;
+ struct pci_dev *pdev = dpriv->pci_priv->pdev;
struct TxFD *tx_fd;
+ dma_addr_t addr;
int next;
+ addr = pci_map_single(pdev, skb->data, skb->len, PCI_DMA_TODEVICE);
+ if (pci_dma_mapping_error(pdev, addr)) {
+ dev_kfree_skb_any(skb);
+ dev->stats.tx_dropped++;
+ return NETDEV_TX_OK;
+ }
+
next = dpriv->tx_current%TX_RING_SIZE;
dpriv->tx_skbuff[next] = skb;
tx_fd = dpriv->tx_fd + next;
tx_fd->state = FrameEnd | TO_STATE_TX(skb->len);
- tx_fd->data = cpu_to_le32(pci_map_single(ppriv->pdev, skb->data, skb->len,
- PCI_DMA_TODEVICE));
+ tx_fd->data = cpu_to_le32(addr);
tx_fd->complete = 0x00000000;
tx_fd->jiffies = jiffies;
mb();
@@ -1887,16 +1902,22 @@ static struct sk_buff *dscc4_init_dummy_skb(struct dscc4_dev_priv *dpriv)
skb = dev_alloc_skb(DUMMY_SKB_SIZE);
if (skb) {
+ struct pci_dev *pdev = dpriv->pci_priv->pdev;
int last = dpriv->tx_dirty%TX_RING_SIZE;
struct TxFD *tx_fd = dpriv->tx_fd + last;
+ dma_addr_t addr;
skb->len = DUMMY_SKB_SIZE;
skb_copy_to_linear_data(skb, version,
strlen(version) % DUMMY_SKB_SIZE);
+ addr = pci_map_single(pdev, skb->data, DUMMY_SKB_SIZE,
+ PCI_DMA_TODEVICE);
+ if (pci_dma_mapping_error(pdev, addr)) {
+ dev_kfree_skb_any(skb);
+ return NULL;
+ }
tx_fd->state = FrameEnd | TO_STATE_TX(DUMMY_SKB_SIZE);
- tx_fd->data = cpu_to_le32(pci_map_single(dpriv->pci_priv->pdev,
- skb->data, DUMMY_SKB_SIZE,
- PCI_DMA_TODEVICE));
+ tx_fd->data = cpu_to_le32(addr);
dpriv->tx_skbuff[last] = skb;
}
return skb;
--
2.7.4
^ permalink raw reply related
* Re: [PATCHv2 net-next iproute2] gre: add support for ERSPAN tunnel
From: Stephen Hemminger @ 2017-08-10 22:12 UTC (permalink / raw)
To: William Tu; +Cc: netdev, Meenakshi Vohra, Alexey Kuznetsov
In-Reply-To: <1502396067-21274-1-git-send-email-u9012063@gmail.com>
On Thu, 10 Aug 2017 13:14:27 -0700
William Tu <u9012063@gmail.com> wrote:
> +
> + if (greinfo[IFLA_GRE_ERSPAN_INDEX])
> + erspan_idx = rta_getattr_u32(greinfo[IFLA_GRE_ERSPAN_INDEX]);
> }
Are you missing a ntohl() here?
It is encoded as htonl() when sending to kernel.
addattr32(n, 1024, IFLA_GRE_FWMARK, fwmark);
+ addattr32(n, 1024, IFLA_GRE_ERSPAN_INDEX, htonl(erspan_idx));
Is erspan_idx == 0 a reserved value?
You should only send erspan_idx to kernel if it is given on command line.
^ permalink raw reply
* (unknown),
From: stef.ryckmans @ 2017-08-10 22:02 UTC (permalink / raw)
To: netdev
[-- Attachment #1: 65496536326505.zip --]
[-- Type: application/zip, Size: 2836 bytes --]
^ permalink raw reply
* [PATCH net-next v2] vxlan: change vxlan_[config_]validate() to use netlink_ext_ack for error reporting
From: Girish Moodalbail @ 2017-08-10 21:16 UTC (permalink / raw)
To: pshelar, davem, netdev, mschiffer, jbenc, roopa
The kernel log is not where users expect error messages for netlink
requests; as we have extended acks now, we can replace pr_debug() with
NL_SET_ERR_MSG_ATTR().
Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
Signed-off-by: Girish Moodalbail <girish.moodalbail@oracle.com>
---
v1 -> v2:
- addressed, error messages rewording, comments from Jiri Benc
- started off with what Matthias had, and I covered error reporting
for all of the unsuccessful returns
---
drivers/net/vxlan.c | 98 +++++++++++++++++++++++++++++++++++++++--------------
1 file changed, 72 insertions(+), 26 deletions(-)
diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
index 35e84a9e..ec302cd7 100644
--- a/drivers/net/vxlan.c
+++ b/drivers/net/vxlan.c
@@ -2729,12 +2729,14 @@ static int vxlan_validate(struct nlattr *tb[], struct nlattr *data[],
{
if (tb[IFLA_ADDRESS]) {
if (nla_len(tb[IFLA_ADDRESS]) != ETH_ALEN) {
- pr_debug("invalid link address (not ethernet)\n");
+ NL_SET_ERR_MSG_ATTR(extack, tb[IFLA_ADDRESS],
+ "Provided link layer address is not Ethernet");
return -EINVAL;
}
if (!is_valid_ether_addr(nla_data(tb[IFLA_ADDRESS]))) {
- pr_debug("invalid all zero ethernet address\n");
+ NL_SET_ERR_MSG_ATTR(extack, tb[IFLA_ADDRESS],
+ "Provided Ethernet address is not unicast");
return -EADDRNOTAVAIL;
}
}
@@ -2742,18 +2744,27 @@ static int vxlan_validate(struct nlattr *tb[], struct nlattr *data[],
if (tb[IFLA_MTU]) {
u32 mtu = nla_get_u32(tb[IFLA_MTU]);
- if (mtu < ETH_MIN_MTU || mtu > ETH_MAX_MTU)
+ if (mtu < ETH_MIN_MTU || mtu > ETH_MAX_MTU) {
+ NL_SET_ERR_MSG_ATTR(extack, tb[IFLA_MTU],
+ "MTU must be between 68 and 65535");
return -EINVAL;
+ }
}
- if (!data)
+ if (!data) {
+ NL_SET_ERR_MSG(extack,
+ "Not enough attributes provided to perform the operation");
return -EINVAL;
+ }
if (data[IFLA_VXLAN_ID]) {
u32 id = nla_get_u32(data[IFLA_VXLAN_ID]);
- if (id >= VXLAN_N_VID)
+ if (id >= VXLAN_N_VID) {
+ NL_SET_ERR_MSG_ATTR(extack, tb[IFLA_VXLAN_ID],
+ "VXLAN ID must be lower than 16777216");
return -ERANGE;
+ }
}
if (data[IFLA_VXLAN_PORT_RANGE]) {
@@ -2761,8 +2772,8 @@ static int vxlan_validate(struct nlattr *tb[], struct nlattr *data[],
= nla_data(data[IFLA_VXLAN_PORT_RANGE]);
if (ntohs(p->high) < ntohs(p->low)) {
- pr_debug("port range %u .. %u not valid\n",
- ntohs(p->low), ntohs(p->high));
+ NL_SET_ERR_MSG_ATTR(extack, tb[IFLA_VXLAN_PORT_RANGE],
+ "Provided source port range bounds is invalid");
return -EINVAL;
}
}
@@ -2919,7 +2930,8 @@ static int vxlan_sock_add(struct vxlan_dev *vxlan)
static int vxlan_config_validate(struct net *src_net, struct vxlan_config *conf,
struct net_device **lower,
- struct vxlan_dev *old)
+ struct vxlan_dev *old,
+ struct netlink_ext_ack *extack)
{
struct vxlan_net *vn = net_generic(src_net, vxlan_net_id);
struct vxlan_dev *tmp;
@@ -2933,6 +2945,8 @@ static int vxlan_config_validate(struct net *src_net, struct vxlan_config *conf,
*/
if ((conf->flags & ~VXLAN_F_ALLOWED_GPE) ||
!(conf->flags & VXLAN_F_COLLECT_METADATA)) {
+ NL_SET_ERR_MSG(extack,
+ "VXLAN GPE does not support this combination of attributes");
return -EINVAL;
}
}
@@ -2947,15 +2961,23 @@ static int vxlan_config_validate(struct net *src_net, struct vxlan_config *conf,
conf->saddr.sa.sa_family = conf->remote_ip.sa.sa_family;
}
- if (conf->saddr.sa.sa_family != conf->remote_ip.sa.sa_family)
+ if (conf->saddr.sa.sa_family != conf->remote_ip.sa.sa_family) {
+ NL_SET_ERR_MSG(extack,
+ "Local and remote address must be from the same family");
return -EINVAL;
+ }
- if (vxlan_addr_multicast(&conf->saddr))
+ if (vxlan_addr_multicast(&conf->saddr)) {
+ NL_SET_ERR_MSG(extack, "Local address cannot be multicast");
return -EINVAL;
+ }
if (conf->saddr.sa.sa_family == AF_INET6) {
- if (!IS_ENABLED(CONFIG_IPV6))
+ if (!IS_ENABLED(CONFIG_IPV6)) {
+ NL_SET_ERR_MSG(extack,
+ "IPv6 support not enabled in the kernel");
return -EPFNOSUPPORT;
+ }
use_ipv6 = true;
conf->flags |= VXLAN_F_IPV6;
@@ -2967,46 +2989,68 @@ static int vxlan_config_validate(struct net *src_net, struct vxlan_config *conf,
if (local_type & IPV6_ADDR_LINKLOCAL) {
if (!(remote_type & IPV6_ADDR_LINKLOCAL) &&
- (remote_type != IPV6_ADDR_ANY))
+ (remote_type != IPV6_ADDR_ANY)) {
+ NL_SET_ERR_MSG(extack,
+ "Invalid combination of local and remote address scopes");
return -EINVAL;
+ }
conf->flags |= VXLAN_F_IPV6_LINKLOCAL;
} else {
if (remote_type ==
- (IPV6_ADDR_UNICAST | IPV6_ADDR_LINKLOCAL))
+ (IPV6_ADDR_UNICAST | IPV6_ADDR_LINKLOCAL)) {
+ NL_SET_ERR_MSG(extack,
+ "Invalid combination of local and remote address scopes");
return -EINVAL;
+ }
conf->flags &= ~VXLAN_F_IPV6_LINKLOCAL;
}
}
}
- if (conf->label && !use_ipv6)
+ if (conf->label && !use_ipv6) {
+ NL_SET_ERR_MSG(extack,
+ "Label attribute only applies for IPv6 VXLAN devices");
return -EINVAL;
+ }
if (conf->remote_ifindex) {
struct net_device *lowerdev;
lowerdev = __dev_get_by_index(src_net, conf->remote_ifindex);
- if (!lowerdev)
+ if (!lowerdev) {
+ NL_SET_ERR_MSG(extack,
+ "Specified interface for tunnel endpoint communications not found");
return -ENODEV;
+ }
#if IS_ENABLED(CONFIG_IPV6)
if (use_ipv6) {
struct inet6_dev *idev = __in6_dev_get(lowerdev);
- if (idev && idev->cnf.disable_ipv6)
+ if (idev && idev->cnf.disable_ipv6) {
+ NL_SET_ERR_MSG(extack,
+ "IPv6 support disabled by administrator");
return -EPERM;
+ }
}
#endif
*lower = lowerdev;
} else {
- if (vxlan_addr_multicast(&conf->remote_ip))
+ if (vxlan_addr_multicast(&conf->remote_ip)) {
+ NL_SET_ERR_MSG(extack,
+ "Interface need to be specified for multicast destination");
+
return -EINVAL;
+ }
#if IS_ENABLED(CONFIG_IPV6)
- if (conf->flags & VXLAN_F_IPV6_LINKLOCAL)
+ if (conf->flags & VXLAN_F_IPV6_LINKLOCAL) {
+ NL_SET_ERR_MSG(extack,
+ "Interface need to be specified for link-local local/remote addresses");
return -EINVAL;
+ }
#endif
*lower = NULL;
@@ -3038,6 +3082,7 @@ static int vxlan_config_validate(struct net *src_net, struct vxlan_config *conf,
tmp->cfg.remote_ifindex != conf->remote_ifindex)
continue;
+ NL_SET_ERR_MSG(extack, "Specified VNI is duplicate");
return -EEXIST;
}
@@ -3097,14 +3142,14 @@ static void vxlan_config_apply(struct net_device *dev,
}
static int vxlan_dev_configure(struct net *src_net, struct net_device *dev,
- struct vxlan_config *conf,
- bool changelink)
+ struct vxlan_config *conf, bool changelink,
+ struct netlink_ext_ack *extack)
{
struct vxlan_dev *vxlan = netdev_priv(dev);
struct net_device *lowerdev;
int ret;
- ret = vxlan_config_validate(src_net, conf, &lowerdev, vxlan);
+ ret = vxlan_config_validate(src_net, conf, &lowerdev, vxlan, extack);
if (ret)
return ret;
@@ -3114,13 +3159,14 @@ static int vxlan_dev_configure(struct net *src_net, struct net_device *dev,
}
static int __vxlan_dev_create(struct net *net, struct net_device *dev,
- struct vxlan_config *conf)
+ struct vxlan_config *conf,
+ struct netlink_ext_ack *extack)
{
struct vxlan_net *vn = net_generic(net, vxlan_net_id);
struct vxlan_dev *vxlan = netdev_priv(dev);
int err;
- err = vxlan_dev_configure(net, dev, conf, false);
+ err = vxlan_dev_configure(net, dev, conf, false, extack);
if (err)
return err;
@@ -3366,7 +3412,7 @@ static int vxlan_newlink(struct net *src_net, struct net_device *dev,
if (err)
return err;
- return __vxlan_dev_create(src_net, dev, &conf);
+ return __vxlan_dev_create(src_net, dev, &conf, extack);
}
static int vxlan_changelink(struct net_device *dev, struct nlattr *tb[],
@@ -3386,7 +3432,7 @@ static int vxlan_changelink(struct net_device *dev, struct nlattr *tb[],
memcpy(&old_dst, dst, sizeof(struct vxlan_rdst));
- err = vxlan_dev_configure(vxlan->net, dev, &conf, true);
+ err = vxlan_dev_configure(vxlan->net, dev, &conf, true, extack);
if (err)
return err;
@@ -3592,7 +3638,7 @@ struct net_device *vxlan_dev_create(struct net *net, const char *name,
if (IS_ERR(dev))
return dev;
- err = __vxlan_dev_create(net, dev, conf);
+ err = __vxlan_dev_create(net, dev, conf, NULL);
if (err < 0) {
free_netdev(dev);
return ERR_PTR(err);
--
1.8.3.1
^ permalink raw reply related
* Re: [PATCH v1 net] TCP_USER_TIMEOUT and tcp_keepalive should conform to RFC5482
From: Rao Shoaib @ 2017-08-10 21:05 UTC (permalink / raw)
To: Jerry Chu
Cc: David Miller, codesoldier1, Yuchung Cheng, Alexey Kuznetsov,
netdev@vger.kernel.org
In-Reply-To: <CAPshTChOnTb8HyRfS5cqjcTjUCpHRvMMuG8WNgLTuhT9Z=+3qA@mail.gmail.com>
On 08/09/2017 09:59 PM, Jerry Chu wrote:
> On Wed, Aug 9, 2017 at 8:32 PM, Jerry Chu <hkchu@google.com> wrote:
>> On Wed, Aug 9, 2017 at 5:47 PM, Rao Shoaib <rao.shoaib@oracle.com> wrote:
>>>
>>> On 08/09/2017 05:30 PM, David Miller wrote:
>>>> From: Joe Smith <codesoldier1@gmail.com>
>>>> Date: Wed, 9 Aug 2017 17:20:32 -0700
>>>>
>>>>> Making Linux conform to standards and behavior that is logical seems
>>>>> like a good enough reason.
>>>> That's an awesome attitude to have when we're implementing something
>>>> new and don't have the facility already.
>>>>
>>>> But when we have something already the only important consideration is
>>>> not breaking existing apps which rely on that behavior.
>>>>
>>>> That is much, much, more important than standards compliance.
>>>>
>>>> If users are confused, just fix the documentation.
>>> David,
>>>
>>> If it was just confusion than sure fixing the documentation is fine. What if
>>> the logic is incorrect, does not conform to the standard that is says it is
>> Not sure what part of logic is "incorrect" when it was a homegrown Linux API
>> with no need to conform with any "standard"? Note that the new API was invented
>> 7 years ago not out of need for RFC5482. In fact I initially call the option
>> TCP_FAILFAST and did not even know the existence of RFC5482 until someone
>> around the same time proposed a UTO option specifically for RFC5482 and I
>> thought the two can be combined. (This is roughly the memory I can
>> recollect so far.)
>>
>> So you see my focus back then was to devise a "failfast" option whereas RFC5482
>> was meant for a "failslow" case. I think that explains why I let the
>> option override
>> keepalive so a TCP connection can "fail fast" while RFC5482 4.2 tries to prevent
>> keepalive failure ahead of UTO, favoring "fail slow".
>>
>> If we start from a clean slate then perhaps one can argue the semantic
>> either way
>> but we do not have a clean slate. For that I still slightly favor not
>> changing the code
>> because the risk of breakage is definitely non-zero and the issue you're having
>> seem to be only related to documentation.
We all make mistakes and over look things, that seems to be the case
here. If this was so important than I am sure there was a use case. None
has been presented. Without a use case I do not understand why we have
to live with broken logic when we have a chance to fix it and make the
code better.
If this change does break something (very very unlikely) we will
understand the use case and provide an appropriate solution.
> One more thing - the proposed patch compares TCP_KEEPIDLE against
> TCP_USER_TIMEOUT. But I don't think TCP_KEEPIDLE is what the
> "keep-alive
> timer" referred to in RFC5482. Linux keepalive implementation seems to use #
> of retries (TCP_KEEPCNT) rather than time duration (keep-alive time) to
> determine when to quit. If that is the case then your proposed change is not
> fully "compliant" either and the best is probably just don't change.
Did you look at the patch and what it changes ?
Take a look at the TCP_KEEPIDLE socket option and see what it does or
just look at the man page of tcp(7)
TCP_KEEPIDLE (since Linux 2.4) The time (in seconds) the connection
needs to remain idle before TCP starts sending keepalive probes, if the
socket option SO_KEEPALIVE has been set on this socket. This option
should not be used in code intended to be portable.
Shoaib.
>
>> Jerry
>>
>>> implementing and easy to fix with little or no risk of breakage.
>>>
>>> The proposed patch changes a feature that no one uses. It also imposes the
>>> relation ship between keepalive and timeout values that is required by the
>>> RFC and make sense.
>>>
>>> You are the final authority, if you say we should just fix the documentation
>>> than that is fine.
>>>
>>> Shoaib
>>>
^ permalink raw reply
* [PATCH net-next] net: ipv4: set orig_oif based on fib result for local traffic
From: David Ahern @ 2017-08-10 20:49 UTC (permalink / raw)
To: netdev; +Cc: David Ahern
Attempts to connect to a local address with a socket bound
to a device with the local address hangs if there is no listener:
$ ip addr sh dev eth1
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether 02:e0:f9:1c:00:37 brd ff:ff:ff:ff:ff:ff
inet 10.100.1.4/24 scope global eth1
valid_lft forever preferred_lft forever
inet6 2001:db8:1::4/120 scope global
valid_lft forever preferred_lft forever
inet6 fe80::e0:f9ff:fe1c:37/64 scope link
valid_lft forever preferred_lft forever
$ vrf-test -I eth1 -r 10.100.1.4
<hangs when there is no server>
(don't let the command name fool you; vrf-test works without vrfs.)
The problem is that the original intended device, eth1 in this case, is
lost when the tcp reset is sent, so the socket lookup does not find a
match for the reset and the connect attempt hangs. Fix by adjusting
orig_oif for local traffic to the device from the fib lookup result.
With this patch you get the more user friendly:
$ vrf-test -I eth1 -r 10.100.1.4
connect failed: 111: Connection refused
orig_oif is saved to the newly created rtable as rt_iif and when set
it is used as the dif for socket lookups. It is set based on flowi4_oif
passed in to ip_route_output_key_hash_rcu and will be set to either
the loopback device, an l3mdev device, nothing (flowi4_oif = 0 which
is the case in the example above) or a netdev index depending on the
lookup path. In each case, resetting orig_oif to the device in the fib
result for the RTN_LOCAL case allows the actual device to be preserved
as the skb tx and rx is done over the loopback or VRF device.
Signed-off-by: David Ahern <dsahern@gmail.com>
---
As far as I can tell the current behavior goes back to the 2.6 days
at least. Not sure it is worth adding to stable branches.
net/ipv4/route.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index 2ef46294475f..aae8f681ce1b 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -2439,6 +2439,12 @@ struct rtable *ip_route_output_key_hash_rcu(struct net *net, struct flowi4 *fl4,
/* L3 master device is the loopback for that domain */
dev_out = l3mdev_master_dev_rcu(FIB_RES_DEV(*res)) ? :
net->loopback_dev;
+
+ /* make sure orig_oif points to fib result device even
+ * though packet rx/tx happens over loopback or l3mdev
+ */
+ orig_oif = FIB_RES_OIF(*res);
+
fl4->flowi4_oif = dev_out->ifindex;
flags |= RTCF_LOCAL;
goto make_route;
--
2.1.4
^ permalink raw reply related
* [PATCH 2/2] drivers: add vpls support
From: Amine Kherbouche @ 2017-08-10 20:28 UTC (permalink / raw)
To: netdev; +Cc: amine.kherbouche, roopa
In-Reply-To: <1502396917-14848-1-git-send-email-amine.kherbouche@6wind.com>
This commit introduces the support of VPLS virtual device, that allows
performing L2VPN multipoint to multipoint communication over MPLS PSN.
VPLS device encap received ethernet frame over mpls packet and send it the
output device, in the other direction, when receiving the right configured
mpls packet, the matched mpls route calls the handler vpls function,
then pulls out the mpls header and send it back the entry point via
netif_rx().
Two functions, mpls_entry_encode() and mpls_output_possible() are
exported from mpls/internal.h to be able to use them inside vpls driver.
Signed-off-by: Amine Kherbouche <amine.kherbouche@6wind.com>
---
drivers/net/Kconfig | 8 +
drivers/net/Makefile | 1 +
drivers/net/vpls.c | 531 +++++++++++++++++++++++++++++++++++++++++++
include/net/mpls.h | 15 ++
include/net/vpls.h | 21 ++
include/uapi/linux/if_link.h | 15 ++
net/mpls/internal.h | 12 -
7 files changed, 591 insertions(+), 12 deletions(-)
create mode 100644 drivers/net/vpls.c
create mode 100644 include/net/vpls.h
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index 83a1616..2ae5a23 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -363,6 +363,14 @@ config VSOCKMON
mostly intended for developers or support to debug vsock issues. If
unsure, say N.
+config VPLS
+ tristate "Virtual Private LAN Service (VPLS)"
+ depends on MPLS_ROUTING
+ ---help---
+ This allows one to create VPLS virtual interfaces that provide
+ Layer 2 Networks multipoint to multipoint communication over MPLS
+ PSN.
+
endif # NET_CORE
config SUNGEM_PHY
diff --git a/drivers/net/Makefile b/drivers/net/Makefile
index b2f6556..7488975 100644
--- a/drivers/net/Makefile
+++ b/drivers/net/Makefile
@@ -31,6 +31,7 @@ obj-$(CONFIG_GTP) += gtp.o
obj-$(CONFIG_NLMON) += nlmon.o
obj-$(CONFIG_NET_VRF) += vrf.o
obj-$(CONFIG_VSOCKMON) += vsockmon.o
+obj-$(CONFIG_VPLS) += vpls.o
#
# Networking Drivers
diff --git a/drivers/net/vpls.c b/drivers/net/vpls.c
new file mode 100644
index 0000000..b51e31a
--- /dev/null
+++ b/drivers/net/vpls.c
@@ -0,0 +1,531 @@
+/*
+ * Copyright (c) 2017 6WIND S.A.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ */
+
+#include <linux/netdevice.h>
+#include <linux/slab.h>
+#include <linux/etherdevice.h>
+#include <linux/u64_stats_sync.h>
+#include <linux/module.h>
+#include <linux/mpls.h>
+
+#include <net/rtnetlink.h>
+#include <net/dst.h>
+#include <net/mpls.h>
+#include <net/vpls.h>
+
+#define DRV_NAME "vpls"
+#define DRV_VERSION "0.1"
+#define VPLS_MAX_ID 256 /* Max VPLS WireID (arbitrary) */
+#define VPLS_DEFAULT_TTL 255 /* Max TTL */
+
+static struct rtnl_link_ops vpls_link_ops;
+
+union vpls_nh {
+ struct in6_addr addr6;
+ struct in_addr addr;
+};
+
+struct vpls_dst {
+ struct net_device *dev;
+ union vpls_nh addr;
+ u32 label_in, label_out;
+ u32 id;
+ u16 vlan_id;
+ u8 via_table;
+ u8 flags;
+ u8 ttl;
+};
+
+struct vpls_priv {
+ struct net *encap_net;
+ struct vpls_dst dst;
+};
+
+static struct nla_policy vpls_policy[IFLA_VPLS_MAX + 1] = {
+ [IFLA_VPLS_ID] = { .type = NLA_U32 },
+ [IFLA_VPLS_IN_LABEL] = { .type = NLA_U32 },
+ [IFLA_VPLS_OUT_LABEL] = { .type = NLA_U32 },
+ [IFLA_VPLS_OIF] = { .type = NLA_U32 },
+ [IFLA_VPLS_TTL] = { .type = NLA_U8 },
+ [IFLA_VPLS_VLANID] = { .type = NLA_U8 },
+ [IFLA_VPLS_NH] = { .type = NLA_U32 },
+ [IFLA_VPLS_NH6] = { .len = sizeof(struct in6_addr) },
+};
+
+static netdev_tx_t vpls_xmit(struct sk_buff *skb, struct net_device *dev)
+{
+ struct vpls_priv *priv = netdev_priv(dev);
+ struct vpls_dst *dst = &priv->dst;
+ struct pcpu_sw_netstats *stats;
+ unsigned int new_header_size;
+ struct net_device *out_dev;
+ struct mpls_shim_hdr *hdr;
+ int ret = NET_RX_DROP;
+ unsigned int hh_len;
+
+ out_dev = dst->dev;
+ skb_orphan(skb);
+ skb_forward_csum(skb);
+ stats = this_cpu_ptr(dev->tstats);
+
+ if (!mpls_output_possible(dst->dev) || skb_warn_if_lro(skb)) {
+ dev->stats.tx_errors++;
+ goto end;
+ }
+
+ new_header_size = 1 * sizeof(struct mpls_shim_hdr);
+
+ hh_len = LL_RESERVED_SPACE(out_dev);
+ if (!out_dev->header_ops)
+ hh_len = 0;
+
+ ret = skb_cow(skb, hh_len + new_header_size);
+ if (ret) {
+ dev->stats.tx_errors++;
+ goto end;
+ }
+
+ skb_push(skb, new_header_size);
+ skb_reset_network_header(skb);
+
+ skb->dev = out_dev;
+ skb->protocol = htons(ETH_P_MPLS_UC);
+
+ hdr = mpls_hdr(skb);
+ hdr[0] = mpls_entry_encode(dst->label_out, dst->ttl, 0, true);
+
+ if (dst->flags & VPLS_F_VLAN)
+ skb_vlan_push(skb, htons(ETH_P_8021Q), dst->vlan_id);
+
+ ret = neigh_xmit(dst->via_table, out_dev, &dst->addr, skb);
+ if (ret) {
+ net_dbg_ratelimited("%s: packet transmission failed: %d\n",
+ __func__, ret);
+ dev->stats.tx_errors++;
+ goto end;
+ }
+
+ u64_stats_update_begin(&stats->syncp);
+ stats->tx_packets++;
+ stats->tx_bytes += skb->len;
+ u64_stats_update_end(&stats->syncp);
+end:
+ return ret;
+}
+
+static int vpls_rcv(void *arg, struct sk_buff *skb, struct net_device *in_dev,
+ u32 label, u8 bos)
+{
+ struct pcpu_sw_netstats *stats;
+ struct net_device *dev;
+ struct vpls_priv *priv;
+ struct vpls_dst *dst;
+
+ dev = arg;
+ priv = netdev_priv(dev);
+ dst = &priv->dst;
+ stats = this_cpu_ptr(dev->tstats);
+
+ if (!bos) {
+ pr_info("%s: incoming BoS mismatch\n", dev->name);
+ goto drop;
+ }
+
+ if (!dst->dev && label != dst->label_in) {
+ pr_info("%s: incoming label %u mismatch\n", dev->name,
+ label);
+ goto drop;
+ }
+
+ if (unlikely(!pskb_may_pull(skb,
+ ETH_HLEN + sizeof(struct mpls_shim_hdr))))
+ goto drop;
+
+ skb->dev = dev;
+ skb_reset_mac_header(skb);
+ skb_pull(skb, sizeof(struct mpls_shim_hdr));
+ skb->protocol = eth_type_trans(skb, dev);
+ skb->ip_summed = CHECKSUM_NONE;
+ skb->pkt_type = PACKET_HOST;
+ skb_clear_hash(skb);
+ skb->vlan_tci = 0;
+ skb_set_queue_mapping(skb, 0);
+ skb_scrub_packet(skb, !net_eq(dev_net(in_dev), dev_net(dev)));
+ skb_reset_network_header(skb);
+ skb_probe_transport_header(skb, 0);
+
+ if (netif_rx(skb) == NET_RX_SUCCESS) {
+ u64_stats_update_begin(&stats->syncp);
+ stats->rx_packets++;
+ stats->rx_bytes += skb->len;
+ u64_stats_update_end(&stats->syncp);
+
+ return NET_RX_SUCCESS;
+ }
+drop:
+ dev->stats.rx_errors++;
+ kfree_skb(skb);
+ return NET_RX_DROP;
+}
+
+/* Stub, nothing needs to be done. */
+static void vpls_set_multicast_list(struct net_device *dev)
+{
+}
+
+static int vpls_open(struct net_device *dev)
+{
+ struct vpls_priv *priv = netdev_priv(dev);
+ struct vpls_dst *dst = &priv->dst;
+ int ret;
+
+ ret = mpls_handler_add(priv->encap_net, dst->label_in,
+ dst->via_table, (u8 *)&dst->addr,
+ vpls_rcv, dev, NULL);
+ /* A mpls route is added when creating the interface, so -EEXIST
+ * is just a confirmation, don't return an error.
+ */
+ if (ret == -EEXIST)
+ ret = 0;
+
+ netif_carrier_on(dev);
+
+ return ret;
+}
+
+static int vpls_close(struct net_device *dev)
+{
+ struct vpls_priv *priv = netdev_priv(dev);
+ struct vpls_dst *dst;
+ int ret;
+
+ dst = &priv->dst;
+ netif_carrier_off(dev);
+ ret = mpls_handler_del(priv->encap_net, dst->label_in, NULL);
+
+ return ret;
+}
+
+static void vpls_dev_get_stats64(struct net_device *dev,
+ struct rtnl_link_stats64 *stats)
+{
+ u64 rx_packets, rx_bytes, tx_packets, tx_bytes;
+ const struct pcpu_sw_netstats *tstats;
+ u64 rx_errors = 0, tx_errors = 0;
+ unsigned int start;
+ int i;
+
+ if (!dev->tstats)
+ return;
+
+ for_each_possible_cpu(i) {
+ tstats = per_cpu_ptr(dev->tstats, i);
+ do {
+ start = u64_stats_fetch_begin_irq(&tstats->syncp);
+ rx_packets = tstats->rx_packets;
+ tx_packets = tstats->tx_packets;
+ rx_bytes = tstats->rx_bytes;
+ tx_bytes = tstats->tx_bytes;
+ } while (u64_stats_fetch_retry_irq(&tstats->syncp, start));
+
+ stats->rx_packets += rx_packets;
+ stats->tx_packets += tx_packets;
+ stats->rx_bytes += rx_bytes;
+ stats->tx_bytes += tx_bytes;
+
+ rx_errors += dev->stats.rx_errors;
+ tx_errors += dev->stats.tx_errors;
+ }
+
+ stats->rx_dropped = rx_errors;
+ stats->tx_dropped = tx_errors;
+ stats->rx_errors = rx_errors;
+ stats->tx_errors = tx_errors;
+}
+
+static int is_valid_vpls_mtu(int new_mtu)
+{
+ return new_mtu >= ETH_MIN_MTU && new_mtu <= ETH_MAX_MTU;
+}
+
+static int vpls_change_mtu(struct net_device *dev, int new_mtu)
+{
+ if (!is_valid_vpls_mtu(new_mtu))
+ return -EINVAL;
+ dev->mtu = new_mtu;
+ return 0;
+}
+
+static int vpls_dev_init(struct net_device *dev)
+{
+ dev->tstats = netdev_alloc_pcpu_stats(struct pcpu_sw_netstats);
+ if (!dev->tstats)
+ return -ENOMEM;
+ return 0;
+}
+
+static const struct net_device_ops vpls_netdev_ops = {
+ .ndo_set_mac_address = eth_mac_addr,
+ .ndo_features_check = passthru_features_check,
+ .ndo_set_rx_mode = vpls_set_multicast_list,
+ .ndo_get_stats64 = vpls_dev_get_stats64,
+ .ndo_start_xmit = vpls_xmit,
+ .ndo_change_mtu = vpls_change_mtu,
+ .ndo_init = vpls_dev_init,
+ .ndo_open = vpls_open,
+ .ndo_stop = vpls_close,
+};
+
+#define VPLS_FEATURES (NETIF_F_SG | NETIF_F_FRAGLIST | \
+ NETIF_F_HW_CSUM | NETIF_F_RXCSUM | NETIF_F_HIGHDMA)
+
+static void vpls_setup(struct net_device *dev)
+{
+ ether_setup(dev);
+
+ dev->priv_flags &= ~IFF_TX_SKB_SHARING;
+ dev->priv_flags |= IFF_LIVE_ADDR_CHANGE;
+ dev->priv_flags |= IFF_NO_QUEUE;
+
+ dev->netdev_ops = &vpls_netdev_ops;
+ dev->features |= NETIF_F_LLTX;
+ dev->features |= VPLS_FEATURES;
+ dev->vlan_features = dev->features;
+ dev->hw_features = VPLS_FEATURES;
+ dev->hw_enc_features = VPLS_FEATURES;
+
+ dev->needs_free_netdev = true;
+}
+
+static int vpls_validate(struct nlattr *tb[], struct nlattr *data[],
+ struct netlink_ext_ack *extack)
+{
+ if (tb[IFLA_ADDRESS]) {
+ if (nla_len(tb[IFLA_ADDRESS]) != ETH_ALEN) {
+ NL_SET_ERR_MSG(extack, "Invalid mac address length");
+ return -EINVAL;
+ }
+ if (!is_valid_ether_addr(nla_data(tb[IFLA_ADDRESS]))) {
+ NL_SET_ERR_MSG(extack, "Invalid mac address");
+ return -EADDRNOTAVAIL;
+ }
+ }
+
+ if (tb[IFLA_MTU])
+ if (!is_valid_vpls_mtu(nla_get_u32(tb[IFLA_MTU]))) {
+ NL_SET_ERR_MSG(extack, "Invalid MTU");
+ return -EINVAL;
+ }
+
+ if (!data) {
+ NL_SET_ERR_MSG(extack, "No vpls data available");
+ return -EINVAL;
+ }
+
+ if (data[IFLA_VPLS_ID]) {
+ __u32 id = nla_get_u32(data[IFLA_VPLS_ID]);
+ if (id >= VPLS_MAX_ID) {
+ NL_SET_ERR_MSG(extack, "vpls id out of range");
+ return -ERANGE;
+ }
+ }
+
+ return 0;
+}
+
+static int vpls_dev_configure(struct net *net, struct net_device *dev,
+ struct nlattr *tb[], struct nlattr *data[],
+ bool changelink, struct netlink_ext_ack *extack)
+{
+ struct vpls_priv *priv = netdev_priv(dev);
+ struct vpls_dst *dst = &priv->dst;
+ struct net_device *outdev;
+ int ret;
+
+ if (!data[IFLA_VPLS_ID] || !data[IFLA_VPLS_OIF] ||
+ !data[IFLA_VPLS_IN_LABEL] || !data[IFLA_VPLS_OUT_LABEL]) {
+ NL_SET_ERR_MSG(extack, "Missing essential arguments");
+ return -EINVAL;
+ }
+
+ if (!tb[IFLA_ADDRESS])
+ eth_hw_addr_random(dev);
+
+ if (tb[IFLA_IFNAME])
+ nla_strlcpy(dev->name, tb[IFLA_IFNAME], IFNAMSIZ);
+ else
+ snprintf(dev->name, IFNAMSIZ, DRV_NAME "%%d");
+
+ outdev = dev_get_by_index(net, nla_get_u32(data[IFLA_VPLS_OIF]));
+ if (!outdev) {
+ NL_SET_ERR_MSG(extack, "Invalid output device");
+ return -EINVAL;
+ }
+
+ priv->encap_net = get_net(net);
+ dst->id = nla_get_u32(data[IFLA_VPLS_ID]);
+ dst->label_in = nla_get_u32(data[IFLA_VPLS_IN_LABEL]);
+ dst->label_out = nla_get_u32(data[IFLA_VPLS_OUT_LABEL]);
+ dst->dev = outdev;
+
+ if (data[IFLA_VPLS_NH]) {
+ dst->addr.addr.s_addr = nla_get_in_addr(data[IFLA_VPLS_NH]);
+ dst->flags |= VPLS_F_INET;
+ dst->via_table = NEIGH_ARP_TABLE;
+ } else if (data[IFLA_VPLS_NH6]) {
+ if (!IS_ENABLED(CONFIG_IPV6)) {
+ NL_SET_ERR_MSG(extack, "IPv6 not enabled");
+ return -EPFNOSUPPORT;
+ }
+ dst->addr.addr6 = nla_get_in6_addr(data[IFLA_VPLS_NH6]);
+ dst->flags |= VPLS_F_INET6;
+ dst->via_table = NEIGH_ND_TABLE;
+ }
+
+ if (data[IFLA_VPLS_VLANID]) {
+ dst->vlan_id = nla_get_u16(data[IFLA_VPLS_VLANID]);
+ dst->flags |= VPLS_F_VLAN;
+ }
+
+ if (data[IFLA_VPLS_TTL])
+ dst->ttl = nla_get_u8(data[IFLA_VPLS_TTL]);
+ else
+ dst->ttl = VPLS_DEFAULT_TTL;
+
+ if (changelink) {
+ ret = mpls_handler_del(priv->encap_net, dst->label_in, extack);
+ if (ret)
+ return ret;
+ }
+
+ ret = mpls_handler_add(priv->encap_net, dst->label_in, dst->via_table,
+ (u8 *)&dst->addr, vpls_rcv, dev, extack);
+ synchronize_rcu();
+
+ return ret;
+}
+
+static int vpls_newlink(struct net *src_net, struct net_device *dev,
+ struct nlattr *tb[], struct nlattr *data[],
+ struct netlink_ext_ack *extack)
+{
+ int err;
+
+ err = vpls_dev_configure(src_net, dev, tb, data, 0, extack);
+ if (err < 0) {
+ NL_SET_ERR_MSG(extack, "Error while configuring VPLS device");
+ goto err;
+ }
+
+ err = register_netdevice(dev);
+ if (err < 0)
+ goto err;
+
+ netif_carrier_off(dev);
+ return 0;
+
+err:
+ return err;
+}
+
+static void vpls_dellink(struct net_device *dev, struct list_head *head)
+{
+ struct vpls_priv *priv = netdev_priv(dev);
+
+ mpls_handler_del(priv->encap_net, priv->dst.label_in, NULL);
+ unregister_netdevice_queue(dev, head);
+}
+
+static int vpls_changelink(struct net_device *dev, struct nlattr *tb[],
+ struct nlattr *data[],
+ struct netlink_ext_ack *extack)
+{
+ struct vpls_priv *priv = netdev_priv(dev);
+ struct net *net;
+ int err;
+
+ net = priv->encap_net;
+ err = vpls_dev_configure(net, dev, tb, data, 1, extack);
+ if (err)
+ NL_SET_ERR_MSG(extack, "Error while configuring VPLS device");
+
+ return err;
+}
+
+static int vpls_fill_info(struct sk_buff *skb, const struct net_device *dev)
+{
+ const struct vpls_priv *priv = netdev_priv(dev);
+ const struct vpls_dst *dst = &priv->dst;
+ struct net_device *out_dev = dst->dev;
+
+ if (nla_put_u32(skb, IFLA_VPLS_ID, dst->id) ||
+ nla_put_u32(skb, IFLA_VPLS_IN_LABEL, dst->label_in) ||
+ nla_put_u32(skb, IFLA_VPLS_OUT_LABEL, dst->label_out) ||
+ nla_put_u32(skb, IFLA_VPLS_OIF, out_dev->ifindex))
+ goto nla_put_failure;
+
+ if (nla_put_u8(skb, IFLA_VPLS_TTL, dst->ttl))
+ goto nla_put_failure;
+
+ if (dst->flags & VPLS_F_VLAN)
+ if (nla_put_u16(skb, IFLA_VPLS_VLANID, dst->vlan_id))
+ goto nla_put_failure;
+
+ if (dst->flags & VPLS_F_INET) {
+ if (nla_put_in_addr(skb, IFLA_VPLS_NH,
+ dst->addr.addr.s_addr))
+ goto nla_put_failure;
+#if IS_ENABLED(CONFIG_IPV6)
+ } else if (dst->flags & VPLS_F_INET6) {
+ if (nla_put_in6_addr(skb, IFLA_VPLS_NH6,
+ &dst->addr.addr6))
+ goto nla_put_failure;
+#endif
+ }
+ return 0;
+
+nla_put_failure:
+ return -EMSGSIZE;
+}
+
+static struct rtnl_link_ops vpls_link_ops = {
+ .changelink = vpls_changelink,
+ .priv_size = sizeof(struct vpls_priv),
+ .fill_info = vpls_fill_info,
+ .validate = vpls_validate,
+ .dellink = vpls_dellink,
+ .newlink = vpls_newlink,
+ .maxtype = IFLA_VPLS_MAX,
+ .policy = vpls_policy,
+ .setup = vpls_setup,
+ .kind = DRV_NAME,
+};
+
+static __init int vpls_init(void)
+{
+ return rtnl_link_register(&vpls_link_ops);
+}
+
+static __exit void vpls_exit(void)
+{
+ rtnl_link_unregister(&vpls_link_ops);
+}
+
+module_init(vpls_init);
+module_exit(vpls_exit);
+
+MODULE_AUTHOR("Amine Kherbouche <amine.kherbouche@6wind.com>");
+MODULE_DESCRIPTION("Virtual Private LAN Service");
+MODULE_ALIAS_RTNL_LINK(DRV_NAME);
+MODULE_VERSION(DRV_VERSION);
+MODULE_LICENSE("GPL v2");
diff --git a/include/net/mpls.h b/include/net/mpls.h
index 0ff51b6..deb2be3 100644
--- a/include/net/mpls.h
+++ b/include/net/mpls.h
@@ -16,6 +16,8 @@
#include <linux/if_ether.h>
#include <linux/netdevice.h>
+#include <linux/kernel.h>
+#include <linux/mpls.h>
#define MPLS_HLEN 4
@@ -34,6 +36,19 @@ static inline struct mpls_shim_hdr *mpls_hdr(const struct sk_buff *skb)
return (struct mpls_shim_hdr *)skb_network_header(skb);
}
+static inline struct mpls_shim_hdr mpls_entry_encode(u32 label, u32 ttl,
+ u32 tc, bool bos)
+{
+ struct mpls_shim_hdr result;
+ result.label_stack_entry =
+ cpu_to_be32((label << MPLS_LS_LABEL_SHIFT) |
+ (tc << MPLS_LS_TC_SHIFT) |
+ (bos ? (1 << MPLS_LS_S_SHIFT) : 0) |
+ (ttl << MPLS_LS_TTL_SHIFT));
+ return result;
+}
+
+bool mpls_output_possible(const struct net_device *dev);
typedef int (*mpls_handler)(void *arg, struct sk_buff *skb,
struct net_device *dev, u32 index, u8 bos);
diff --git a/include/net/vpls.h b/include/net/vpls.h
new file mode 100644
index 0000000..f1111bc
--- /dev/null
+++ b/include/net/vpls.h
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2017 6WIND S.A.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ */
+
+#ifndef _VPLS_H
+#define _VPLS_H
+
+#define VPLS_F_INET 0x01
+#define VPLS_F_INET6 0x02
+#define VPLS_F_VLAN 0x04
+
+#endif /* _VPLS_H */
diff --git a/include/uapi/linux/if_link.h b/include/uapi/linux/if_link.h
index 8d062c5..3952c54 100644
--- a/include/uapi/linux/if_link.h
+++ b/include/uapi/linux/if_link.h
@@ -458,6 +458,21 @@ enum macsec_validation_type {
MACSEC_VALIDATE_MAX = __MACSEC_VALIDATE_END - 1,
};
+/* VPLS section */
+enum {
+ IFLA_VPLS_UNSPEC,
+ IFLA_VPLS_ID,
+ IFLA_VPLS_IN_LABEL,
+ IFLA_VPLS_OUT_LABEL,
+ IFLA_VPLS_OIF,
+ IFLA_VPLS_TTL,
+ IFLA_VPLS_VLANID,
+ IFLA_VPLS_NH,
+ IFLA_VPLS_NH6,
+ __IFLA_VPLS_MAX
+};
+#define IFLA_VPLS_MAX (__IFLA_VPLS_MAX - 1)
+
/* IPVLAN section */
enum {
IFLA_IPVLAN_UNSPEC,
diff --git a/net/mpls/internal.h b/net/mpls/internal.h
index 2cd73eb..64a48a5 100644
--- a/net/mpls/internal.h
+++ b/net/mpls/internal.h
@@ -174,17 +174,6 @@ struct mpls_route { /* next hop label forwarding entry */
#define endfor_nexthops(rt) }
-static inline struct mpls_shim_hdr mpls_entry_encode(u32 label, unsigned ttl, unsigned tc, bool bos)
-{
- struct mpls_shim_hdr result;
- result.label_stack_entry =
- cpu_to_be32((label << MPLS_LS_LABEL_SHIFT) |
- (tc << MPLS_LS_TC_SHIFT) |
- (bos ? (1 << MPLS_LS_S_SHIFT) : 0) |
- (ttl << MPLS_LS_TTL_SHIFT));
- return result;
-}
-
static inline struct mpls_entry_decoded mpls_entry_decode(struct mpls_shim_hdr *hdr)
{
struct mpls_entry_decoded result;
@@ -207,7 +196,6 @@ int nla_put_labels(struct sk_buff *skb, int attrtype, u8 labels,
const u32 label[]);
int nla_get_labels(const struct nlattr *nla, u8 max_labels, u8 *labels,
u32 label[], struct netlink_ext_ack *extack);
-bool mpls_output_possible(const struct net_device *dev);
unsigned int mpls_dev_mtu(const struct net_device *dev);
bool mpls_pkt_too_big(const struct sk_buff *skb, unsigned int mtu);
void mpls_stats_inc_outucastpkts(struct net_device *dev,
--
2.1.4
^ permalink raw reply related
* [PATCH 1/2] mpls: add handlers
From: Amine Kherbouche @ 2017-08-10 20:28 UTC (permalink / raw)
To: netdev; +Cc: amine.kherbouche, roopa, David Lamparter
In-Reply-To: <1502396917-14848-1-git-send-email-amine.kherbouche@6wind.com>
Mpls handler allows creation/deletion of mpls routes without using
rtnetlink. When an incoming mpls packet matches this route, the saved
function handler is called.
Signed-off-by: Amine Kherbouche <amine.kherbouche@6wind.com>
Signed-off-by: David Lamparter <equinox@diac24.net>
---
include/net/mpls.h | 10 +++++++
net/mpls/af_mpls.c | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++++
net/mpls/internal.h | 3 +++
3 files changed, 88 insertions(+)
diff --git a/include/net/mpls.h b/include/net/mpls.h
index 1dbc669..0ff51b6 100644
--- a/include/net/mpls.h
+++ b/include/net/mpls.h
@@ -33,4 +33,14 @@ static inline struct mpls_shim_hdr *mpls_hdr(const struct sk_buff *skb)
{
return (struct mpls_shim_hdr *)skb_network_header(skb);
}
+
+typedef int (*mpls_handler)(void *arg, struct sk_buff *skb,
+ struct net_device *dev, u32 index, u8 bos);
+
+extern int mpls_handler_add(struct net *net, u32 index, u8 via_table, u8 via[],
+ mpls_handler handler, void *handler_arg,
+ struct netlink_ext_ack *extack);
+extern int mpls_handler_del(struct net *net, u32 index,
+ struct netlink_ext_ack *extack);
+
#endif
diff --git a/net/mpls/af_mpls.c b/net/mpls/af_mpls.c
index c5b9ce4..82d2126 100644
--- a/net/mpls/af_mpls.c
+++ b/net/mpls/af_mpls.c
@@ -10,6 +10,7 @@
#include <linux/netconf.h>
#include <linux/vmalloc.h>
#include <linux/percpu.h>
+#include <net/mpls.h>
#include <net/ip.h>
#include <net/dst.h>
#include <net/sock.h>
@@ -299,6 +300,7 @@ static bool mpls_egress(struct net *net, struct mpls_route *rt,
success = true;
break;
}
+ case MPT_HANDLER:
case MPT_UNSPEC:
/* Should have decided which protocol it is by now */
break;
@@ -356,6 +358,10 @@ static int mpls_forward(struct sk_buff *skb, struct net_device *dev,
goto drop;
}
+ if (rt->rt_payload_type == MPT_HANDLER)
+ return rt->rt_handler(rt->rt_harg, skb, dev,
+ dec.label, dec.bos);
+
nh = mpls_select_multipath(rt, skb);
if (!nh)
goto err;
@@ -457,6 +463,8 @@ static const struct nla_policy rtm_mpls_policy[RTA_MAX+1] = {
struct mpls_route_config {
u32 rc_protocol;
u32 rc_ifindex;
+ mpls_handler rc_handler;
+ void *rc_harg;
u8 rc_via_table;
u8 rc_via_alen;
u8 rc_via[MAX_VIA_ALEN];
@@ -995,6 +1003,11 @@ static int mpls_route_add(struct mpls_route_config *cfg,
rt->rt_payload_type = cfg->rc_payload_type;
rt->rt_ttl_propagate = cfg->rc_ttl_propagate;
+ if (cfg->rc_handler) {
+ rt->rt_handler = cfg->rc_handler;
+ rt->rt_harg = cfg->rc_harg;
+ }
+
if (cfg->rc_mp)
err = mpls_nh_build_multi(cfg, rt, max_labels, extack);
else
@@ -1271,6 +1284,68 @@ static int mpls_netconf_dump_devconf(struct sk_buff *skb,
return skb->len;
}
+int mpls_handler_add(struct net *net, u32 label, u8 via_table, u8 via[],
+ mpls_handler handler, void *handler_arg,
+ struct netlink_ext_ack *extack)
+{
+ struct net_device *dev = handler_arg;
+ struct mpls_route_config *cfg;
+ u8 alen = 0;
+ int err;
+
+ cfg = kzalloc(sizeof(*cfg), GFP_KERNEL);
+ if (!cfg)
+ return -ENOMEM;
+
+ memset(cfg, 0, sizeof(*cfg));
+ if (via_table == NEIGH_ARP_TABLE)
+ alen = sizeof(struct in_addr);
+ else if (via_table == NEIGH_ND_TABLE)
+ alen = sizeof(struct in6_addr);
+
+ cfg->rc_ttl_propagate = MPLS_TTL_PROP_DEFAULT;
+ cfg->rc_protocol = RTPROT_KERNEL;
+ cfg->rc_nlflags |= NLM_F_CREATE;
+ cfg->rc_payload_type = MPT_HANDLER;
+ cfg->rc_via_table = via_table;
+ cfg->rc_label = label;
+ cfg->rc_via_alen = alen;
+ memcpy(&cfg->rc_via, via, alen);
+ cfg->rc_ifindex = dev->ifindex;
+ cfg->rc_nlinfo.nl_net = net;
+ cfg->rc_harg = handler_arg;
+ cfg->rc_handler = handler;
+ cfg->rc_output_labels = 0;
+
+ err = mpls_route_add(cfg, extack);
+ kfree(cfg);
+
+ return err;
+}
+EXPORT_SYMBOL(mpls_handler_add);
+
+int mpls_handler_del(struct net *net, u32 index,
+ struct netlink_ext_ack *extack)
+{
+ struct mpls_route_config *cfg;
+ int err = 0;
+
+ cfg = kzalloc(sizeof(*cfg), GFP_KERNEL);
+ if (!cfg)
+ return -ENOMEM;
+
+ memset(cfg, 0, sizeof(*cfg));
+ cfg->rc_protocol = RTPROT_KERNEL;
+ cfg->rc_label = index;
+ cfg->rc_nlinfo.nl_net = net;
+
+ err = mpls_route_del(cfg, extack);
+ kfree(cfg);
+
+ return err;
+}
+EXPORT_SYMBOL(mpls_handler_del);
+
#define MPLS_PERDEV_SYSCTL_OFFSET(field) \
(&((struct mpls_dev *)0)->field)
diff --git a/net/mpls/internal.h b/net/mpls/internal.h
index cf65aec..2cd73eb 100644
--- a/net/mpls/internal.h
+++ b/net/mpls/internal.h
@@ -78,6 +78,7 @@ enum mpls_payload_type {
MPT_UNSPEC, /* IPv4 or IPv6 */
MPT_IPV4 = 4,
MPT_IPV6 = 6,
+ MPT_HANDLER = 255,
/* Other types not implemented:
* - Pseudo-wire with or without control word (RFC4385)
@@ -141,6 +142,8 @@ enum mpls_ttl_propagation {
*/
struct mpls_route { /* next hop label forwarding entry */
struct rcu_head rt_rcu;
+ mpls_handler rt_handler;
+ void *rt_harg;
u8 rt_protocol;
u8 rt_payload_type;
u8 rt_max_alen;
--
2.1.4
^ permalink raw reply related
* [RFC PATCH 0/2] Support of VPLS MPLS
From: Amine Kherbouche @ 2017-08-10 20:28 UTC (permalink / raw)
To: netdev; +Cc: amine.kherbouche, roopa
This small series implements the support of VPLS dataplane using MPLS
encapsulation to perform a l2VPN using a virtual network device.
The ingress ethernet frames are encapsulated and carried over an MPLS packet
switched network, then decapsulated in the egress router (LER) by a vpls
device.
This small schema describe how to configure a vpls device to perform l2VPN
over MPLS PSN:
in LER0:
- ip link add name br0 type bridge
- ip link set dev0 master br0
- ip link add name vpls0 type vpls id 10 output 111 input 222 \
via {{dev3_addr}} dev dev1
- ip link set vpls0 master br0
in LER1:
- ip link add name br1 type bridge
- ip link set dev2 master br0
- ip link add name vpls1 type vpls id 20 output 222 input 111 \
via {{dev1_addr}} dev dev3
- ip link set vpls1 master br1
LER0 LER1
+--------------+ +--------------+
| | | |
| +- br0--+ | | vpls1 |
| | | | +--------+ | | |
------- dev0+ | | | | | | +-dev2 ----------
| | dev1 --- |MPLS PSN| --- dev3 | | |
10.1.0.0/24| | | | | | | | | 10.1.0.0/24
| vpls0 | +--------+ | +--br1-+ |
| | | |
+--------------+ +--------------+
packet dissection:
| |
ether0/ip0/payload | ether1/mpls0/ether0/ip0/payload | ether0/ip0/payload
| |
An Iproute2 patch is available to complete this serie here:
https://github.com/6WIND/iproute2/commit/0d1d3f2a5733421baf08e247d4ce2fb03cd666f1
Example of more detailed configurations with iproute2:
Create a VPLS vdev "vpls0" to neighbor 10.200.0.2 via dev1, encapsulate the
incoming Ethernet frame from the bridge in MPLS packets with label 111 with
ttl 10 and uncap recieved MPLS packets from dev1 with label 222:
ip link add name vpls0 type vpls id 10 output 111 input 222 ttl 10 \
via 10.200.0.2 dev dev1
Same configuration than the previous one just use Ipv6:
ip link add name vpls0 type vpls id 10 output 111 input 222 ttl 10 \
via fd00:200::2 dev dev1
Now the same configuration but tag the outer Ethernet frame with vlan id 55:
ip link add name vpls0 type vpls id 10 output 111 input 222 vlan 55 \
ttl 10 via 10.200.0.2 dev dev1
The approch for configuration is from OpenBSD, more information:
https://man.openbsd.org/mpw.4
TODO next:
- Support of Pseudowire Emulation Edge-to-Edge (PWE3) datapath.
https://tools.ietf.org/html/rfc4385
- Add the support of lightweight VPLS tunnel for scalability. ie one device
with many tunnels.
^ permalink raw reply
* [PATCHv2 net-next iproute2] gre: add support for ERSPAN tunnel
From: William Tu @ 2017-08-10 20:14 UTC (permalink / raw)
To: netdev; +Cc: Meenakshi Vohra, Stephen Hemminger, Alexey Kuznetsov
The patch adds ERSPAN type II tunnel support. The implementation
is based on the draft at https://tools.ietf.org/html/draft-foschiano-erspan-01
One of the purposes is for Linux box to be able to receive ERSPAN
monitoring traffic sent from the Cisco switch, by creating a ERSPAN
tunnel device. In addition, the patch also adds ERSPAN TX, so traffic
can also be encapsulated into ERSPAN and sent out.
The implementation reuses the key as ERSPAN session ID, and
field 'erspan' as ERSPAN Index fields:
./ip link add dev ers11 type erspan seq key 100 erspan 123 \
local 172.16.1.200 remote 172.16.1.100
Signed-off-by: William Tu <u9012063@gmail.com>
Signed-off-by: Meenakshi Vohra <mvohra@vmware.com>
Cc: Stephen Hemminger <stephen@networkplumber.org>
Cc: Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>
---
v1->v2:
Add manual entry for ERSPAN.
Check 20-bit ERSPAN index field.
---
include/linux/if_tunnel.h | 1 +
ip/ipaddress.c | 2 +-
ip/iplink.c | 5 +++--
ip/link_gre.c | 28 +++++++++++++++++++++++++++-
man/man8/ip-address.8.in | 1 +
man/man8/ip-link.8.in | 19 ++++++++++++++++---
6 files changed, 49 insertions(+), 7 deletions(-)
diff --git a/include/linux/if_tunnel.h b/include/linux/if_tunnel.h
index 7375335a0773..21834cac4c0d 100644
--- a/include/linux/if_tunnel.h
+++ b/include/linux/if_tunnel.h
@@ -134,6 +134,7 @@ enum {
IFLA_GRE_COLLECT_METADATA,
IFLA_GRE_IGNORE_DF,
IFLA_GRE_FWMARK,
+ IFLA_GRE_ERSPAN_INDEX,
__IFLA_GRE_MAX,
};
diff --git a/ip/ipaddress.c b/ip/ipaddress.c
index 4d37c5e04507..f7296991e483 100644
--- a/ip/ipaddress.c
+++ b/ip/ipaddress.c
@@ -76,7 +76,7 @@ static void usage(void)
fprintf(stderr, "LFT := forever | SECONDS\n");
fprintf(stderr, "TYPE := { vlan | veth | vcan | dummy | ifb | macvlan | macvtap |\n");
fprintf(stderr, " bridge | bond | ipoib | ip6tnl | ipip | sit | vxlan | lowpan |\n");
- fprintf(stderr, " gre | gretap | ip6gre | ip6gretap | vti | nlmon | can |\n");
+ fprintf(stderr, " gre | gretap | erspan | ip6gre | ip6gretap | vti | nlmon | can |\n");
fprintf(stderr, " bond_slave | ipvlan | geneve | bridge_slave | vrf | hsr | macsec }\n");
exit(-1);
diff --git a/ip/iplink.c b/ip/iplink.c
index 5aff2fde38da..62430110bfab 100644
--- a/ip/iplink.c
+++ b/ip/iplink.c
@@ -112,8 +112,9 @@ void iplink_usage(void)
"\n"
"TYPE := { vlan | veth | vcan | dummy | ifb | macvlan | macvtap |\n"
" bridge | bond | team | ipoib | ip6tnl | ipip | sit | vxlan |\n"
- " gre | gretap | ip6gre | ip6gretap | vti | nlmon | team_slave |\n"
- " bond_slave | ipvlan | geneve | bridge_slave | vrf | macsec }\n");
+ " gre | gretap | erspan | ip6gre | ip6gretap | vti | nlmon |\n"
+ " team_slave | bond_slave | ipvlan | geneve | bridge_slave |\n"
+ " vrf | macsec }\n");
}
exit(-1);
}
diff --git a/ip/link_gre.c b/ip/link_gre.c
index c2ec5f26902f..e3fcab3a8ca7 100644
--- a/ip/link_gre.c
+++ b/ip/link_gre.c
@@ -26,7 +26,7 @@
static void print_usage(FILE *f)
{
fprintf(f,
- "Usage: ... { gre | gretap } [ remote ADDR ]\n"
+ "Usage: ... { gre | gretap | erspan } [ remote ADDR ]\n"
" [ local ADDR ]\n"
" [ [i|o]seq ]\n"
" [ [i|o]key KEY ]\n"
@@ -44,6 +44,7 @@ static void print_usage(FILE *f)
" [ [no]encap-csum6 ]\n"
" [ [no]encap-remcsum ]\n"
" [ fwmark MARK ]\n"
+ " [ erspan IDX ]\n"
"\n"
"Where: ADDR := { IP_ADDRESS | any }\n"
" TOS := { NUMBER | inherit }\n"
@@ -96,6 +97,7 @@ static int gre_parse_opt(struct link_util *lu, int argc, char **argv,
__u8 metadata = 0;
__u8 ignore_df = 0;
__u32 fwmark = 0;
+ __u32 erspan_idx = 0;
if (!(n->nlmsg_flags & NLM_F_CREATE)) {
if (rtnl_talk(&rth, &req.n, &req.n, sizeof(req)) < 0) {
@@ -172,6 +174,9 @@ get_failed:
if (greinfo[IFLA_GRE_FWMARK])
fwmark = rta_getattr_u32(greinfo[IFLA_GRE_FWMARK]);
+
+ if (greinfo[IFLA_GRE_ERSPAN_INDEX])
+ erspan_idx = rta_getattr_u32(greinfo[IFLA_GRE_ERSPAN_INDEX]);
}
while (argc > 0) {
@@ -328,6 +333,12 @@ get_failed:
NEXT_ARG();
if (get_u32(&fwmark, *argv, 0))
invarg("invalid fwmark\n", *argv);
+ } else if (strcmp(*argv, "erspan") == 0) {
+ NEXT_ARG();
+ if (get_u32(&erspan_idx, *argv, 0))
+ invarg("invalid erspan index\n", *argv);
+ if (erspan_idx & ~((1<<20) - 1))
+ invarg("erspan index must be <= 20-bit\n", *argv);
} else
usage();
argc--; argv++;
@@ -359,6 +370,7 @@ get_failed:
addattr_l(n, 1024, IFLA_GRE_TTL, &ttl, 1);
addattr_l(n, 1024, IFLA_GRE_TOS, &tos, 1);
addattr32(n, 1024, IFLA_GRE_FWMARK, fwmark);
+ addattr32(n, 1024, IFLA_GRE_ERSPAN_INDEX, htonl(erspan_idx));
} else {
addattr_l(n, 1024, IFLA_GRE_COLLECT_METADATA, NULL, 0);
}
@@ -473,6 +485,12 @@ static void gre_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
if (tb[IFLA_GRE_IGNORE_DF] && rta_getattr_u8(tb[IFLA_GRE_IGNORE_DF]))
fputs("ignore-df ", f);
+ if (tb[IFLA_GRE_ERSPAN_INDEX]) {
+ __u32 erspan_idx = rta_getattr_u32(tb[IFLA_GRE_ERSPAN_INDEX]);
+
+ fprintf(f, "erspan_index %u", erspan_idx);
+ }
+
if (tb[IFLA_GRE_ENCAP_TYPE] &&
rta_getattr_u16(tb[IFLA_GRE_ENCAP_TYPE]) != TUNNEL_ENCAP_NONE) {
__u16 type = rta_getattr_u16(tb[IFLA_GRE_ENCAP_TYPE]);
@@ -538,3 +556,11 @@ struct link_util gretap_link_util = {
.print_opt = gre_print_opt,
.print_help = gre_print_help,
};
+
+struct link_util erspan_link_util = {
+ .id = "erspan",
+ .maxattr = IFLA_GRE_MAX,
+ .parse_opt = gre_parse_opt,
+ .print_opt = gre_print_opt,
+ .print_help = gre_print_help,
+};
diff --git a/man/man8/ip-address.8.in b/man/man8/ip-address.8.in
index 43385813a134..988a79652f6f 100644
--- a/man/man8/ip-address.8.in
+++ b/man/man8/ip-address.8.in
@@ -120,6 +120,7 @@ ip-address \- protocol address management
.BR sit " |"
.BR gre " |"
.BR gretap " |"
+.BR erspan " |"
.BR ip6gre " |"
.BR ip6gretap " |"
.BR vti " |"
diff --git a/man/man8/ip-link.8.in b/man/man8/ip-link.8.in
index c0207281905d..851b308cbe1a 100644
--- a/man/man8/ip-link.8.in
+++ b/man/man8/ip-link.8.in
@@ -202,6 +202,7 @@ ip-link \- network device configuration
.BR sit " |"
.BR gre " |"
.BR gretap " |"
+.BR erspan " |"
.BR ip6gre " |"
.BR ip6gretap " |"
.BR vti " |"
@@ -297,6 +298,9 @@ Link types:
.BR gretap
- Virtual L2 tunnel interface GRE over IPv4
.sp
+.BR erspan
+- Encapsulated Remote SPAN over GRE and IPv4
+.sp
.BR ip6gre
- Virtual tunnel interface GRE over IPv6
.sp
@@ -643,13 +647,13 @@ keyword.
.in -8
.TP
-GRE, IPIP, SIT Type Support
+GRE, IPIP, SIT, ERSPAN Type Support
For a link of types
-.I GRE/IPIP/SIT
+.I GRE/IPIP/SIT/ERSPAN
the following additional arguments are supported:
.BI "ip link add " DEVICE
-.BR type " { " gre " | " ipip " | " sit " }"
+.BR type " { " gre " | " ipip " | " sit " | " erspan " }"
.BI " remote " ADDR " local " ADDR
[
.BR encap " { " fou " | " gue " | " none " }"
@@ -663,6 +667,8 @@ the following additional arguments are supported:
.I " [no]encap-remcsum "
] [
.I " mode " { ip6ip | ipip | mplsip | any } "
+] [
+.BR erspan " \fIIDX "
]
.in +8
@@ -707,6 +713,13 @@ MPLS-Over-IPv4, "any" indicates IPv6, IPv4 or MPLS Over IPv4. Supported for
SIT where the default is "ip6ip" and IPIP where the default is "ipip".
IPv6-Over-IPv4 is not supported for IPIP.
+.sp
+.BR erspan " \fIIDX "
+- specifies the ERSPAN index field.
+.IR IDX
+indicates a 20 bit index/port number associated with the ERSPAN
+traffic's source port and direction.
+
.in -8
.TP
--
2.7.4
^ permalink raw reply related
* Re: unregister_netdevice: waiting for eth0 to become free. Usage count = 1
From: Wei Wang @ 2017-08-10 20:06 UTC (permalink / raw)
To: John Stultz
Cc: Cong Wang, lkml, Network Development, Linux USB List,
David S. Miller, Felipe Balbi, Martin KaFai Lau
In-Reply-To: <CALAqxLUoV6EQvofTEv9whW1_QMPBPU7eJBhRFUjaSs7CGeRFww@mail.gmail.com>
On Thu, Aug 10, 2017 at 11:12 AM, John Stultz <john.stultz@linaro.org> wrote:
> On Wed, Aug 9, 2017 at 10:41 PM, Wei Wang <weiwan@google.com> wrote:
>> Hi John,
>>
>> Is it possible to try the attached patch?
>
> Thanks so much for the quick turn around!
>
> So I dropped all the reverts you suggested, and applied this one
> against 4.13-rc4, but I'm still seeing the problematic behavior.
>
Thanks for confirming.
I have been going through the code and not yet found any leaks.
I am also trying to reproduce the issue myself.
Martin seems to also see this issue.
I will continue investigating.
>> I am not sure if it actually fixes the issue. But I think it is worth a try.
>> Also, could you get me all the ipv6 routes when you plug in the usb
>> using "ip -6 route show"? (If you have multiple routing tables
>> configured, could you dump them all?)
>
> # ip -6 route show
> 2601:1c2:1002:83f0::/64 dev eth0 proto kernel metric 256 expires
> 345599sec pref medium
> fe80::/64 dev eth0 proto kernel metric 256 pref medium
> default via fe80::200:caff:fe11:2233 dev eth0 proto ra metric 1024
> expires 1799sec hoplimit 64 pref medium
>
>
> After unplugging the device (and getting the unregister_netdevice errors):
> # ip -6 route show
> #
>
Thanks for the logs.
>
> thanks
> -john
^ permalink raw reply
* Re: [PATCH 2/6] wl1251: Use request_firmware_prefer_user() for loading NVS calibration data
From: Luis R. Rodriguez @ 2017-08-10 19:43 UTC (permalink / raw)
To: Arend van Spriel, Lennart Poettering
Cc: Luis R. Rodriguez, Li, Yi, Johannes Berg, Pavel Machek,
Daniel Wagner, Tom Gundersen, Pali Rohár, Greg Kroah-Hartman,
Kalle Valo, David Gnedt, Tony Lindgren, Sebastian Reichel,
Ivaylo Dimitrov, Aaro Koskinen, Takashi Iwai, AKASHI Takahiro,
David Woodhouse, Bjorn Andersson, Grazvydas Ignotas
In-Reply-To: <a956b366-95d9-e876-4dba-149d2987633a@broadcom.com>
On Fri, Jun 30, 2017 at 11:35:41PM +0200, Arend van Spriel wrote:
> On 23-06-17 23:53, Luis R. Rodriguez wrote:
> > On Tue, May 16, 2017 at 10:41:08AM +0200, Arend Van Spriel wrote:
> >> On 16-5-2017 1:13, Luis R. Rodriguez wrote:
> >>> Since no upstream delta is needed for firmwared I'd like to first encourage
> >>> evaluating the above. While distributions don't carry it yet that may be seen as
> >>> an issue but since what we are looking for are corner cases, only folks needing
> >>> to deploy a specific solution would need it or a custom proprietary solution.
> >>
> >> Ok. I will go try and run firmwared in OpenWrt on a router platform.
> >> Have to steal one from a colleague :-p Will study firmwared.
> >
> > Arend, curious how this effort goes. Its important to me as we know then that
> > if this works its a good approach to recommend moving forward which should also
> > prove less complex than that soup we had with the custom fallback stuff.
>
> Hi Luis,
>
> So I looked at firmwared and we basically need to extend it.
And actually as me and Johannes spoke long ago at Plumbers, its rather
expected folks would need this or just fork it off completely. firmwared
would just be a reference codebase on how to do these custom loaders.
*How regular* Linux distributions embrace this is still up in the air then,
because as Lennart has pointed out there is no plan to merge firmwared
to systemd.
*If* this is a requirement only for non-upstream drivers or patches on
which will not be merged upstream then this will work long term. If you
need regular distros to do something custom then their respective upstream
tools would need to be evaluated for how something similar would be done.
As far as I can tell perhaps the remote-proc thing would count as one
possible use-case for upstream drivers -- but even then the systems
that use it seem likely to use Android and then some custom userspace.
> For our
> router platform we need to obtain nvram calibration data from an MTD
> partition which contains the raw data, ie. no file-system on it. So
> firmwared would need some sort of configuration to map a particular
> firmware file to some action obtaining the data like kicking off some
> mtd-utils in my case.
I see. So platform specific.
Thanks for the update!
Luis
^ permalink raw reply
* Re: [PATCH RFC 0/2] stap: Socket tap
From: David Ahern @ 2017-08-10 19:26 UTC (permalink / raw)
To: Tom Herbert, netdev; +Cc: rohit
In-Reply-To: <20170807221204.15724-1-tom@quantonium.net>
On 8/7/17 4:12 PM, Tom Herbert wrote:
> A socket tap is enabled on socket using SO_ULP socket option with
> ulp type "stap". The socket option takes ULP specific configuration
How about sktap instead of stap since stap has a history of referring to
system tap?
^ permalink raw reply
* Re: [PATCH] MAINTAINERS: update the NetLabel and Labeled Networking information
From: David Miller @ 2017-08-10 19:25 UTC (permalink / raw)
To: paul; +Cc: netdev, linux-security-module, selinux
In-Reply-To: <CAHC9VhSk1veoZJvHjVnSy6ztyDdoHBQOVWMyXb8X4Db+-xXENw@mail.gmail.com>
From: Paul Moore <paul@paul-moore.com>
Date: Thu, 10 Aug 2017 15:15:23 -0400
> On Thu, Aug 10, 2017 at 3:13 PM, Paul Moore <pmoore@redhat.com> wrote:
>> From: Paul Moore <paul@paul-moore.com>
>>
>> Signed-off-by: Paul Moore <paul@paul-moore.com>
>> ---
>> MAINTAINERS | 24 ++++++++++++++----------
>> 1 file changed, 14 insertions(+), 10 deletions(-)
>
> I'm planning on sending this up via the SELinux tree with some other
> MAINTAINERS updates, consider this more of a FYI posting.
Yep, works for me:
Acked-by: David S. Miller <davem@davemloft.net>
^ permalink raw reply
* Re: [PATCH] MAINTAINERS: update the NetLabel and Labeled Networking information
From: Paul Moore @ 2017-08-10 19:15 UTC (permalink / raw)
To: netdev, linux-security-module, selinux
In-Reply-To: <150239239837.19177.4190318681371376062.stgit@sifl>
On Thu, Aug 10, 2017 at 3:13 PM, Paul Moore <pmoore@redhat.com> wrote:
> From: Paul Moore <paul@paul-moore.com>
>
> Signed-off-by: Paul Moore <paul@paul-moore.com>
> ---
> MAINTAINERS | 24 ++++++++++++++----------
> 1 file changed, 14 insertions(+), 10 deletions(-)
I'm planning on sending this up via the SELinux tree with some other
MAINTAINERS updates, consider this more of a FYI posting.
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 65990909fe73..be25ebaaeec3 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -9112,15 +9112,6 @@ F: net/*/netfilter/
> F: net/netfilter/
> F: net/bridge/br_netfilter*.c
>
> -NETLABEL
> -M: Paul Moore <paul@paul-moore.com>
> -W: http://netlabel.sf.net
> -L: netdev@vger.kernel.org
> -S: Maintained
> -F: Documentation/netlabel/
> -F: include/net/netlabel.h
> -F: net/netlabel/
> -
> NETROM NETWORK LAYER
> M: Ralf Baechle <ralf@linux-mips.org>
> L: linux-hams@vger.kernel.org
> @@ -9248,10 +9239,23 @@ F: net/ipv6/
> F: include/net/ip*
> F: arch/x86/net/*
>
> -NETWORKING [LABELED] (NetLabel, CIPSO, Labeled IPsec, SECMARK)
> +NETWORKING [LABELED] (NetLabel, Labeled IPsec, SECMARK)
> M: Paul Moore <paul@paul-moore.com>
> +W: https://github.com/netlabel
> L: netdev@vger.kernel.org
> +L: linux-security-module@vger.kernel.org
> S: Maintained
> +F: Documentation/netlabel/
> +F: include/net/calipso.h
> +F: include/net/cipso_ipv4.h
> +F: include/net/netlabel.h
> +F: include/uapi/linux/netfilter/xt_SECMARK.h
> +F: include/uapi/linux/netfilter/xt_CONNSECMARK.h
> +F: net/netlabel/
> +F: net/ipv4/cipso_ipv4.c
> +F: net/ipv6/calipso.c
> +F: net/netfilter/xt_CONNSECMARK.c
> +F: net/netfilter/xt_SECMARK.c
>
> NETWORKING [TLS]
> M: Ilya Lesokhin <ilyal@mellanox.com>
--
paul moore
www.paul-moore.com
^ permalink raw reply
* Re: [PATCH V4 net 0/2] ipv6: fix flowlabel issue for reset packet
From: Shaohua Li @ 2017-08-10 19:13 UTC (permalink / raw)
To: Tom Herbert; +Cc: Linux Kernel Network Developers, David S. Miller, Shaohua Li
In-Reply-To: <CALx6S35UKD3AyqxM-zKMCANi=TR_e26mRjKYKH7QreckBu2dEg@mail.gmail.com>
On Thu, Aug 10, 2017 at 11:30:51AM -0700, Tom Herbert wrote:
> On Thu, Aug 10, 2017 at 9:30 AM, Shaohua Li <shli@kernel.org> wrote:
> > On Wed, Aug 09, 2017 at 09:40:08AM -0700, Tom Herbert wrote:
> >> On Mon, Jul 31, 2017 at 3:19 PM, Shaohua Li <shli@kernel.org> wrote:
> >> > From: Shaohua Li <shli@fb.com>
> >> >
> >> > Please see below tcpdump output:
> >> > 21:00:48.109122 IP6 (flowlabel 0x43304, hlim 64, next-header TCP (6) payload length: 40) fec0::5054:ff:fe12:3456.55804 > fec0::5054:ff:fe12:3456.5555: Flags [S], cksum 0x0529 (incorrect -> 0xf56c), seq 3282214508, win 43690, options [mss 65476,sackOK,TS val 2500903437 ecr 0,nop,wscale 7], length 0
> >> > 21:00:48.109381 IP6 (flowlabel 0xd827f, hlim 64, next-header TCP (6) payload length: 40) fec0::5054:ff:fe12:3456.5555 > fec0::5054:ff:fe12:3456.55804: Flags [S.], cksum 0x0529 (incorrect -> 0x49ad), seq 1923801573, ack 3282214509, win 43690, options [mss 65476,sackOK,TS val 2500903437 ecr 2500903437,nop,wscale 7], length 0
> >> > 21:00:48.109548 IP6 (flowlabel 0x43304, hlim 64, next-header TCP (6) payload length: 32) fec0::5054:ff:fe12:3456.55804 > fec0::5054:ff:fe12:3456.5555: Flags [.], cksum 0x0521 (incorrect -> 0x1bdf), seq 1, ack 1, win 342, options [nop,nop,TS val 2500903437 ecr 2500903437], length 0
> >> > 21:00:48.109823 IP6 (flowlabel 0x43304, hlim 64, next-header TCP (6) payload length: 62) fec0::5054:ff:fe12:3456.55804 > fec0::5054:ff:fe12:3456.5555: Flags [P.], cksum 0x053f (incorrect -> 0xb8b1), seq 1:31, ack 1, win 342, options [nop,nop,TS val 2500903437 ecr 2500903437], length 30
> >> > 21:00:48.109910 IP6 (flowlabel 0xd827f, hlim 64, next-header TCP (6) payload length: 32) fec0::5054:ff:fe12:3456.5555 > fec0::5054:ff:fe12:3456.55804: Flags [.], cksum 0x0521 (incorrect -> 0x1bc1), seq 1, ack 31, win 342, options [nop,nop,TS val 2500903437 ecr 2500903437], length 0
> >> > 21:00:48.110043 IP6 (flowlabel 0xd827f, hlim 64, next-header TCP (6) payload length: 56) fec0::5054:ff:fe12:3456.5555 > fec0::5054:ff:fe12:3456.55804: Flags [P.], cksum 0x0539 (incorrect -> 0xb726), seq 1:25, ack 31, win 342, options [nop,nop,TS val 2500903438 ecr 2500903437], length 24
> >> > 21:00:48.110173 IP6 (flowlabel 0x43304, hlim 64, next-header TCP (6) payload length: 32) fec0::5054:ff:fe12:3456.55804 > fec0::5054:ff:fe12:3456.5555: Flags [.], cksum 0x0521 (incorrect -> 0x1ba7), seq 31, ack 25, win 342, options [nop,nop,TS val 2500903438 ecr 2500903438], length 0
> >> > 21:00:48.110211 IP6 (flowlabel 0xd827f, hlim 64, next-header TCP (6) payload length: 32) fec0::5054:ff:fe12:3456.5555 > fec0::5054:ff:fe12:3456.55804: Flags [F.], cksum 0x0521 (incorrect -> 0x1ba7), seq 25, ack 31, win 342, options [nop,nop,TS val 2500903438 ecr 2500903437], length 0
> >> > 21:00:48.151099 IP6 (flowlabel 0x43304, hlim 64, next-header TCP (6) payload length: 32) fec0::5054:ff:fe12:3456.55804 > fec0::5054:ff:fe12:3456.5555: Flags [.], cksum 0x0521 (incorrect -> 0x1ba6), seq 31, ack 26, win 342, options [nop,nop,TS val 2500903438 ecr 2500903438], length 0
> >> > 21:00:49.110524 IP6 (flowlabel 0x43304, hlim 64, next-header TCP (6) payload length: 56) fec0::5054:ff:fe12:3456.55804 > fec0::5054:ff:fe12:3456.5555: Flags [P.], cksum 0x0539 (incorrect -> 0xb324), seq 31:55, ack 26, win 342, options [nop,nop,TS val 2500904438 ecr 2500903438], length 24
> >> > 21:00:49.110637 IP6 (flowlabel 0xb34d5, hlim 64, next-header TCP (6) payload length: 20) fec0::5054:ff:fe12:3456.5555 > fec0::5054:ff:fe12:3456.55804: Flags [R], cksum 0x0515 (incorrect -> 0x668c), seq 1923801599, win 0, length 0
> >> >
> >> > The flowlabel of reset packet (0xb34d5) and flowlabel of normal packet
> >> > (0xd827f) are different. This causes our router doesn't correctly close tcp
> >> > connection. The patches try to fix the issue.
> >> >
> >> Shaohua,
> >>
> >> Can you give some more detail about what the router doesn't close the
> >> TCP connection means? I'm guessing the problem is either: 1) the
> >> router is maintaining connection state that includes the flow label in
> >> a connection tuple. 2) some router in the path is maintaining
> >> connection state, but when the flow label changes the flow's packet
> >> are routed through a different router that doesn't have a state for
> >> the flow it drops the packet. #1 should be easily fix in the router,
> >> flow labels cannot be used as state. #2 is the known problem that
> >> stateful firewalls have killed our ability to use multihoming.
> >
> > The #2 is exactly the problem we saw.
> >
> >> Another consideration is that sk_txhash is also used in routing
> >> decisions by the local host (flow label is normally derived from
> >> txhash). If you want to ensure that connections are routed
> >> consistently for timewait state you might need sk_txhash saved also.
> >
> > As far as I understood, we don't use sk_txhash for routing selection. The code
> > does routing selection with flowlabel user configured, at that time we don't
> > derive fl6.flowlabel from skb->hash (which is from sk_txhash). The code always
> > does routing selection first and then uses ip6_make_flowlabel to build packet
> > data where we derive flowlabel from skb->hash.
> >
> That is assuming one particular use case. Generally, if you want to
> ensure all packets for a flow take the same path you'll need tx_hash
> and make it persistent (disable flow bender). For instance, if you
> were doing UDP encapsulation like in VXLAN the UDP source port
> selection is unaffected by saved flow label for the lifetime of the
> flow. So we would still hit #2 in that case and the stateful device
> doesn't see whole flow. It might be just as easy to move tx_hash in
> skc_common so that it's available in TW state for this purpose. Then
> when moving to TW state just copy the tx_hash.
Hi Tom,
My original implementation is to add a tx_hash in tw sock, we then copy sock's
tx_hash to the tw tx_hash. This does makes things simplier. One concern from
Eric is this will increase the size of tw sock. If we move tx_hash to
skc_common, all sock size will increase, is this acceptable?
Thanks,
Shaohua
^ permalink raw reply
* [PATCH] MAINTAINERS: update the NetLabel and Labeled Networking information
From: Paul Moore @ 2017-08-10 19:13 UTC (permalink / raw)
To: linux-security-module; +Cc: netdev, selinux
From: Paul Moore <paul@paul-moore.com>
Signed-off-by: Paul Moore <paul@paul-moore.com>
---
MAINTAINERS | 24 ++++++++++++++----------
1 file changed, 14 insertions(+), 10 deletions(-)
diff --git a/MAINTAINERS b/MAINTAINERS
index 65990909fe73..be25ebaaeec3 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -9112,15 +9112,6 @@ F: net/*/netfilter/
F: net/netfilter/
F: net/bridge/br_netfilter*.c
-NETLABEL
-M: Paul Moore <paul@paul-moore.com>
-W: http://netlabel.sf.net
-L: netdev@vger.kernel.org
-S: Maintained
-F: Documentation/netlabel/
-F: include/net/netlabel.h
-F: net/netlabel/
-
NETROM NETWORK LAYER
M: Ralf Baechle <ralf@linux-mips.org>
L: linux-hams@vger.kernel.org
@@ -9248,10 +9239,23 @@ F: net/ipv6/
F: include/net/ip*
F: arch/x86/net/*
-NETWORKING [LABELED] (NetLabel, CIPSO, Labeled IPsec, SECMARK)
+NETWORKING [LABELED] (NetLabel, Labeled IPsec, SECMARK)
M: Paul Moore <paul@paul-moore.com>
+W: https://github.com/netlabel
L: netdev@vger.kernel.org
+L: linux-security-module@vger.kernel.org
S: Maintained
+F: Documentation/netlabel/
+F: include/net/calipso.h
+F: include/net/cipso_ipv4.h
+F: include/net/netlabel.h
+F: include/uapi/linux/netfilter/xt_SECMARK.h
+F: include/uapi/linux/netfilter/xt_CONNSECMARK.h
+F: net/netlabel/
+F: net/ipv4/cipso_ipv4.c
+F: net/ipv6/calipso.c
+F: net/netfilter/xt_CONNSECMARK.c
+F: net/netfilter/xt_SECMARK.c
NETWORKING [TLS]
M: Ilya Lesokhin <ilyal@mellanox.com>
^ permalink raw reply related
* Re: [PATCH] bonding: require speed/duplex only for 802.3ad, alb and tlb
From: Mahesh Bandewar (महेश बंडेवार) @ 2017-08-10 19:04 UTC (permalink / raw)
To: Andreas Born; +Cc: linux-netdev
In-Reply-To: <20170810044144.17398-1-futur.andy@googlemail.com>
On Wed, Aug 9, 2017 at 9:41 PM, Andreas Born <futur.andy@googlemail.com> wrote:
> The patch c4adfc822bf5 ("bonding: make speed, duplex setting consistent
> with link state") puts the link state to down if
> bond_update_speed_duplex() cannot retrieve speed and duplex settings.
> Assumably the patch was written with 802.3ad mode in mind which relies
> on link speed/duplex settings. For other modes like active-backup these
> settings are not required.
> Thus, only for these other modes, this patch
> reintroduces support for slaves that do not support reporting speed or
> duplex such as wireless devices. This fixes the regression reported in
> bug 196547 (https://bugzilla.kernel.org/show_bug.cgi?id=196547).
>
> Fixes: c4adfc822bf5 ("bonding: make speed, duplex setting consistent
> with link state")
> Signed-off-by: Andreas Born <futur.andy@googlemail.com>
Acked-by: Mahesh Bandewar <maheshb@google.com>
> ---
> drivers/net/bonding/bond_main.c | 6 ++++--
> include/net/bonding.h | 5 +++++
> 2 files changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
> index 9bee6c1c70cc..85bb272d2a34 100644
> --- a/drivers/net/bonding/bond_main.c
> +++ b/drivers/net/bonding/bond_main.c
> @@ -1569,7 +1569,8 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
> new_slave->delay = 0;
> new_slave->link_failure_count = 0;
>
> - if (bond_update_speed_duplex(new_slave))
> + if (bond_update_speed_duplex(new_slave) &&
> + bond_needs_speed_duplex(bond))
> new_slave->link = BOND_LINK_DOWN;
>
> new_slave->last_rx = jiffies -
> @@ -2140,7 +2141,8 @@ static void bond_miimon_commit(struct bonding *bond)
> continue;
>
> case BOND_LINK_UP:
> - if (bond_update_speed_duplex(slave)) {
> + if (bond_update_speed_duplex(slave) &&
> + bond_needs_speed_duplex(bond)) {
> slave->link = BOND_LINK_DOWN;
> netdev_warn(bond->dev,
> "failed to get link speed/duplex for %s\n",
> diff --git a/include/net/bonding.h b/include/net/bonding.h
> index b00508d22e0a..b2e68657a216 100644
> --- a/include/net/bonding.h
> +++ b/include/net/bonding.h
> @@ -277,6 +277,11 @@ static inline bool bond_is_lb(const struct bonding *bond)
> BOND_MODE(bond) == BOND_MODE_ALB;
> }
>
> +static inline bool bond_needs_speed_duplex(const struct bonding *bond)
> +{
> + return BOND_MODE(bond) == BOND_MODE_8023AD || bond_is_lb(bond);
> +}
> +
> static inline bool bond_is_nondyn_tlb(const struct bonding *bond)
> {
> return (BOND_MODE(bond) == BOND_MODE_TLB) &&
> --
> 2.14.0
>
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox