3
3
# Error codes
4
4
# @see /usr/include/sysexits.h
5
5
6
- # readonly EX_OK=0 # /* successful termination */
7
- # readonly EX__BASE=64 # /* base value for error messages */
8
- # readonly EX_USAGE=64 # /* command line usage error */
6
+ readonly EX_OK=0 # /* successful termination */
7
+ readonly EX__BASE=64 # /* base value for error messages */
8
+ readonly EX_USAGE=64 # /* command line usage error */
9
9
readonly EX_DATAERR=65 # /* data format error */
10
10
readonly EX_NOINPUT=66 # /* cannot open input */
11
- # readonly EX_NOUSER=67 # /* addressee unknown */
12
- # readonly EX_NOHOST=68 # /* host name unknown */
13
- # readonly EX_UNAVAILABLE=69 # /* service unavailable */
14
- # readonly EX_SOFTWARE=70 # /* internal software error */
15
- # readonly EX_OSERR=71 # /* system error (e.g., can't fork) */
16
- # readonly EX_OSFILE=72 # /* critical OS file missing */
17
- # readonly EX_CANTCREAT=73 # /* can't create (user) output file */
11
+ readonly EX_NOUSER=67 # /* addressee unknown */
12
+ readonly EX_NOHOST=68 # /* host name unknown */
13
+ readonly EX_UNAVAILABLE=69 # /* service unavailable */
14
+ readonly EX_SOFTWARE=70 # /* internal software error */
15
+ readonly EX_OSERR=71 # /* system error (e.g., can't fork) */
16
+ readonly EX_OSFILE=72 # /* critical OS file missing */
17
+ readonly EX_CANTCREAT=73 # /* can't create (user) output file */
18
18
readonly EX_IOERR=74 # /* input/output error */
19
- # readonly EX_TEMPFAIL=75 # /* temp failure; user is invited to retry */
20
- # readonly EX_PROTOCOL=76 # /* remote error in protocol */
21
- # readonly EX_NOPERM=77 # /* permission denied */
22
- # readonly EX_CONFIG=78 # /* configuration error */
19
+ readonly EX_TEMPFAIL=75 # /* temp failure; user is invited to retry */
20
+ readonly EX_PROTOCOL=76 # /* remote error in protocol */
21
+ readonly EX_NOPERM=77 # /* permission denied */
22
+ readonly EX_CONFIG=78 # /* configuration error */
23
23
24
24
if [ -n " ${CDIR+x} " ]; then
25
25
readonly export EBPF_CLI=" ${CDIR} /ebpf_py_cli.py"
@@ -53,7 +53,7 @@ function dev_exists()
53
53
return ${EX_DATAERR}
54
54
fi
55
55
56
- ip link show " ${ifname} " > /dev/null 2>&1
56
+ ip link show ${ifname} > /dev/null 2>&1
57
57
return $?
58
58
}
59
59
@@ -66,26 +66,26 @@ function move_ip_addr()
66
66
local res
67
67
local i
68
68
69
- addrs=" $( get_ip_addr " ${src_dev} " ) " || return $?
69
+ addrs=" $( get_ip_addr ${src_dev} ) " || return $?
70
70
71
71
res=0
72
72
for i in ${addrs} ; do
73
73
# we skip ipv6 link-local addresses
74
- echo " ${i} " | grep -q -E ' ^fe80::' && continue ;
74
+ echo ${i} | grep -q -E ' ^fe80::' && continue ;
75
75
76
- ip addr add " ${i} " dev " ${dst_dev} " || { res=$? ; break ; }
76
+ ip addr add ${i} dev ${dst_dev} || { res=$? ; break ; }
77
77
done
78
78
79
79
if [ ${res} -ne 0 ]; then
80
- ip addr flush dev " ${dst_dev} " || return $?
80
+ ip addr flush dev ${dst_dev} || return $?
81
81
return ${EX_IOERR}
82
82
fi
83
83
84
84
for i in ${addrs} ; do
85
85
# we skip ipv6 link-local addresses
86
- echo " ${i} " | grep -q -E ' ^fe80::' && continue
86
+ echo ${i} | grep -q -E ' ^fe80::' && continue
87
87
88
- ip addr del " ${i} " dev " ${src_dev} "
88
+ ip addr del ${i} dev ${src_dev}
89
89
done
90
90
91
91
return 0
@@ -104,11 +104,11 @@ function clean_netdev()
104
104
ifname_egr=" ${ifname} _egr"
105
105
ifname_br=" ${ifname} _br"
106
106
107
- dev_exists " ${ifname_igr} " && move_ip_addr " ${ifname} " " ${ifname_igr} "
107
+ dev_exists ${ifname_igr} && move_ip_addr ${ifname} ${ifname_igr}
108
108
109
- ip link del " ${ifname_igr} " > /dev/null 2>&1
109
+ ip link del ${ifname_igr} > /dev/null 2>&1
110
110
# we do not need to delete _egr because it's a side of a veth pair
111
- ip link del " ${ifname_br} " > /dev/null 2>&1
111
+ ip link del ${ifname_br} > /dev/null 2>&1
112
112
113
113
return 0
114
114
}
@@ -124,40 +124,40 @@ function prepare_netdev()
124
124
dev_exists " ${ifname} " || return $?
125
125
126
126
# clean the node if needed
127
- clean_netdev " ${ifname} "
127
+ clean_netdev ${ifname}
128
128
129
129
ifname_igr=" ${ifname} _igr"
130
130
ifname_egr=" ${ifname} _egr"
131
131
ifname_br=" ${ifname} _br"
132
132
133
- ip link add dev " ${ifname_igr} " type veth peer name " ${ifname_egr} " \
133
+ ip link add dev ${ifname_igr} type veth peer name ${ifname_egr} \
134
134
|| return $?
135
135
136
136
# we create the bridge for interconnecting the ifname_egr with the
137
137
# ifname.
138
138
#
139
139
# NOTE: goto does not exist... so we need to get something similar with
140
140
# if (true) { if(..) break; }
141
- if true ; then
142
- ip link add name " ${ifname_br} " type bridge \
143
- || { res=$? ; return ; }
144
- ip link set dev " ${ifname_egr} " master " ${ifname_br} " \
145
- || { res=$? ; return ; }
146
- ip link set dev " ${ifname} " master " ${ifname_br} " \
147
- || { res=$? ; return ; }
148
-
149
- ip link set dev " ${ifname_br} " up || { res=$? ; return ; }
150
- ip link set dev " ${ifname_igr} " up || { res=$? ; return ; }
151
- ip link set dev " ${ifname_egr} " up || { res=$? ; return ; }
141
+ if [ 1 ] ; then
142
+ ip link add name ${ifname_br} type bridge \
143
+ || { res=$? ; break ; }
144
+ ip link set dev ${ifname_egr} master ${ifname_br} \
145
+ || { res=$? ; break ; }
146
+ ip link set dev ${ifname} master ${ifname_br} \
147
+ || { res=$? ; break ; }
148
+
149
+ ip link set dev ${ifname_br} up || { res=$? ; break ; }
150
+ ip link set dev ${ifname_igr} up || { res=$? ; break ; }
151
+ ip link set dev ${ifname_egr} up || { res=$? ; break ; }
152
152
fi
153
153
154
154
if [ $res -ne 0 ]; then
155
155
# clean up
156
- clean_node " ${ifname} "
156
+ clean_node ${ifname}
157
157
fi
158
158
159
- move_ip_addr " ${ifname_igr} " " ${ifname} " \
160
- || { res=$? ; clean_netdev " ${ifname} " ; return ${res} ; }
159
+ move_ip_addr ${ifname_igr} ${ifname} \
160
+ || { res=$? ; clean_netdev ${ifname} ; return ${res} ; }
161
161
162
162
return 0
163
163
}
@@ -180,7 +180,7 @@ function prepare_daemon_conf()
180
180
return ${EX_NOINPUT}
181
181
fi
182
182
183
- dev_exists " ${ifname} " || return $?
183
+ dev_exists ${ifname} || return $?
184
184
ifname_igr=" ${ifname} _igr"
185
185
186
186
# i.e: filename from zebra.conf to ebpf_zebra.conf with the full path
@@ -264,7 +264,7 @@ function xdp_pfplm_get_color()
264
264
ifname_egr=" ${ifname} _egr"
265
265
266
266
color=" $( " ${EBPF_CLI} " get_color " ${ifname_egr} " ) " || return $?
267
- echo " ${color} "
267
+ echo ${color}
268
268
269
269
return 0
270
270
}
0 commit comments