blob: f67b51df7490779b17ed73162c95152e78dd13fe (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0
source ppp_common.sh
VETH_SERVER="veth-server"
VETH_CLIENT="veth-client"
PPPOE_LOG=$(mktemp /tmp/pppoe.XXXXXX)
# shellcheck disable=SC2329
cleanup() {
cleanup_all_ns
[ -n "$SOCAT_PID" ] && kill_process "$SOCAT_PID"
rm -f "$PPPOE_LOG"
}
trap cleanup EXIT
require_command pppoe-server
ppp_common_init
modprobe -q pppoe
# Try to locate pppoe.so plugin
PPPOE_PLUGIN=$(find /usr/{lib,lib64,lib32}/pppd/ -name pppoe.so -type f -print -quit)
if [ -z "$PPPOE_PLUGIN" ]; then
log_test_skip "PPPoE: pppoe.so plugin not found"
exit "$EXIT_STATUS"
fi
# Create the veth pair
ip link add "$VETH_SERVER" type veth peer name "$VETH_CLIENT"
ip link set "$VETH_SERVER" netns "$NS_SERVER"
ip link set "$VETH_CLIENT" netns "$NS_CLIENT"
ip -netns "$NS_SERVER" link set "$VETH_SERVER" up
ip -netns "$NS_CLIENT" link set "$VETH_CLIENT" up
# Start socat as syslog listener
socat -v -u UNIX-RECV:/dev/log OPEN:/dev/null > "$PPPOE_LOG" 2>&1 &
SOCAT_PID=$!
# Start the PPP Server. Note that versions before 4.0 ignore -g option and
# instead use a hardcoded plugin path, so they may fail to find the plugin.
ip netns exec "$NS_SERVER" pppoe-server -I "$VETH_SERVER" \
-L "$IP_SERVER" -R "$IP_CLIENT" -N 1 -q "$(command -v pppd)" \
-k -O "$(pwd)/pppoe-server-options" -g "$PPPOE_PLUGIN"
# Start the PPP Client
ip netns exec "$NS_CLIENT" pppd \
local debug updetach noipdefault noauth nodefaultroute \
plugin "$PPPOE_PLUGIN" nic-"$VETH_CLIENT"
ppp_test_connectivity
log_test "PPPoE"
# Dump syslog messages if the test failed
if [ "$RET" -ne 0 ]; then
while read -r _sign _date _time len _from _to
do len=${len##*=}
read -n "$len" -r LINE
echo "$LINE"
done < "$PPPOE_LOG"
fi
exit "$EXIT_STATUS"
|