Revision 8ba29adf9a7cdff3c7283d5fc0dcf5e777d3b40f authored by Namhyung Kim on 08 June 2017, 07:31:06 UTC, committed by Arnaldo Carvalho de Melo on 08 June 2017, 18:39:13 UTC
On failure, it should free the 'name', so clean up the error path using
goto.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Suggested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Wang Nan <wangnan0@huawei.com>
Cc: kernel-team@lge.com
Link: http://lkml.kernel.org/r/20170608073109.30699-7-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent 1d6b3c9
Raw File
test_cgrp2_sock.sh
#!/bin/bash

function config_device {
	ip netns add at_ns0
	ip link add veth0 type veth peer name veth0b
	ip link set veth0b up
	ip link set veth0 netns at_ns0
	ip netns exec at_ns0 ip addr add 172.16.1.100/24 dev veth0
	ip netns exec at_ns0 ip addr add 2401:db00::1/64 dev veth0 nodad
	ip netns exec at_ns0 ip link set dev veth0 up
	ip link add foo type vrf table 1234
	ip link set foo up
	ip addr add 172.16.1.101/24 dev veth0b
	ip addr add 2401:db00::2/64 dev veth0b nodad
	ip link set veth0b master foo
}

function attach_bpf {
	rm -rf /tmp/cgroupv2
	mkdir -p /tmp/cgroupv2
	mount -t cgroup2 none /tmp/cgroupv2
	mkdir -p /tmp/cgroupv2/foo
	test_cgrp2_sock /tmp/cgroupv2/foo foo
	echo $$ >> /tmp/cgroupv2/foo/cgroup.procs
}

function cleanup {
	set +ex
	ip netns delete at_ns0
	ip link del veth0
	ip link del foo
	umount /tmp/cgroupv2
	rm -rf /tmp/cgroupv2
	set -ex
}

function do_test {
	ping -c1 -w1 172.16.1.100
	ping6 -c1 -w1 2401:db00::1
}

cleanup 2>/dev/null
config_device
attach_bpf
do_test
cleanup
echo "*** PASS ***"
back to top