Skip to content

Commit 4f2e86f

Browse files
authored
Merge pull request #22 from netgroup/fix-ebpf-in-srv6-pm-topo
Clean and fix 8r-1c-srv6-pm topology
2 parents d05f817 + d1f61e6 commit 4f2e86f

File tree

131 files changed

+1050
-1428
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

131 files changed

+1050
-1428
lines changed

.github/workflows/shell_linter.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Shell Linter
2+
3+
# Controls when the action will run. Triggers the workflow on push or pull request
4+
# events but only for the master branch
5+
on:
6+
push:
7+
branches: [ master ]
8+
pull_request:
9+
branches: [ master ]
10+
11+
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
12+
jobs:
13+
shell-lint:
14+
# The type of runner that the job will run on
15+
runs-on: ubuntu-latest
16+
17+
# Steps represent a sequence of tasks that will be executed as part of the job
18+
steps:
19+
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
20+
- uses: actions/checkout@v2
21+
22+
- name: Shell Linter
23+
uses: reviewdog/action-shellcheck@v1
24+
with:
25+
github_token: ${{ secrets.github_token }}
26+
reporter: github-pr-review # Change reporter.
27+
path: "." # Optional.
28+
pattern: "*.sh" # Optional.
29+
exclude: "./.git/*" # Optional.
30+
fail_on_error: true
31+
level: "info"
32+
shellcheck_flags: --severity=style --external-sources
33+
filter_mode: "nofilter"

nets/3routers/nodeconf/h1/start.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#!/bin/sh
22

3-
BASE_DIR=/home/user/mytests/ospf3routers/nodeconf
43
NODE_NAME=h1
54
GW_NAME=r1
65
IF_NAME=$NODE_NAME-$GW_NAME

nets/3routers/nodeconf/h2/start.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#!/bin/sh
22

3-
BASE_DIR=/home/user/mytests/ospf3routers/nodeconf
43
NODE_NAME=h2
54
GW_NAME=r2
65
IF_NAME=$NODE_NAME-$GW_NAME

nets/3routers/nodeconf/h3/start.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#!/bin/sh
22

3-
BASE_DIR=/home/user/mytests/ospf3routers/nodeconf
43
NODE_NAME=h3
54
GW_NAME=r3
65
IF_NAME=$NODE_NAME-$GW_NAME

nets/3routers/nodeconf/r1/start.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,16 @@ sysctl -w net.ipv4.ip_forward=1
1212
#sysctl -w net.ipv4.conf.default.rp_filter=0
1313
#the following for loop also disables all and default
1414
for i in /proc/sys/net/ipv4/conf/*/rp_filter ; do
15-
echo 0 > $i
15+
echo 0 > "$i"
1616
done
1717

1818

1919
echo "no service integrated-vtysh-config" >> /etc/frr/vtysh.conf
2020
chown frr:frrvty $BASE_DIR/$NODE_NAME
2121
#chown quagga:quagga $BASE_DIR/$NODE_NAME
2222

23-
$FRR_PATH/zebra -f $PWD/$BASE_DIR/$NODE_NAME/zebra.conf -d -z $PWD/$BASE_DIR/$NODE_NAME/zebra.sock -i $PWD/$BASE_DIR/$NODE_NAME/zebra.pid
23+
$FRR_PATH/zebra -f "$PWD"/$BASE_DIR/$NODE_NAME/zebra.conf -d -z "$PWD"/$BASE_DIR/$NODE_NAME/zebra.sock -i "$PWD"/$BASE_DIR/$NODE_NAME/zebra.pid
2424

2525
sleep 1
2626

27-
$FRR_PATH/ospfd -f $PWD/$BASE_DIR/$NODE_NAME/ospfd.conf -d -z $PWD/$BASE_DIR/$NODE_NAME/zebra.sock -i $PWD/$BASE_DIR/$NODE_NAME/ospfd.pid
27+
$FRR_PATH/ospfd -f "$PWD"/$BASE_DIR/$NODE_NAME/ospfd.conf -d -z "$PWD"/$BASE_DIR/$NODE_NAME/zebra.sock -i "$PWD"/$BASE_DIR/$NODE_NAME/ospfd.pid

nets/3routers/nodeconf/r2/start.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,16 @@ sysctl -w net.ipv4.ip_forward=1
1212
#sysctl -w net.ipv4.conf.default.rp_filter=0
1313
#the following for loop also disables all and default
1414
for i in /proc/sys/net/ipv4/conf/*/rp_filter ; do
15-
echo 0 > $i
15+
echo 0 > "$i"
1616
done
1717

1818

1919
echo "no service integrated-vtysh-config" >> /etc/frr/vtysh.conf
2020
chown frr:frrvty $BASE_DIR/$NODE_NAME
2121
#chown quagga:quagga $BASE_DIR/$NODE_NAME
2222

23-
$FRR_PATH/zebra -f $PWD/$BASE_DIR/$NODE_NAME/zebra.conf -d -z $PWD/$BASE_DIR/$NODE_NAME/zebra.sock -i $PWD/$BASE_DIR/$NODE_NAME/zebra.pid
23+
$FRR_PATH/zebra -f "$PWD"/$BASE_DIR/$NODE_NAME/zebra.conf -d -z "$PWD"/$BASE_DIR/$NODE_NAME/zebra.sock -i "$PWD"/$BASE_DIR/$NODE_NAME/zebra.pid
2424

2525
sleep 1
2626

27-
$FRR_PATH/ospfd -f $PWD/$BASE_DIR/$NODE_NAME/ospfd.conf -d -z $PWD/$BASE_DIR/$NODE_NAME/zebra.sock -i $PWD/$BASE_DIR/$NODE_NAME/ospfd.pid
27+
$FRR_PATH/ospfd -f "$PWD"/$BASE_DIR/$NODE_NAME/ospfd.conf -d -z "$PWD"/$BASE_DIR/$NODE_NAME/zebra.sock -i "$PWD"/$BASE_DIR/$NODE_NAME/ospfd.pid

nets/3routers/nodeconf/r3/start.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,16 @@ sysctl -w net.ipv4.ip_forward=1
1212
#sysctl -w net.ipv4.conf.default.rp_filter=0
1313
#the following for loop also disables all and default
1414
for i in /proc/sys/net/ipv4/conf/*/rp_filter ; do
15-
echo 0 > $i
15+
echo 0 > "$i"
1616
done
1717

1818

1919
echo "no service integrated-vtysh-config" >> /etc/frr/vtysh.conf
2020
chown frr:frrvty $BASE_DIR/$NODE_NAME
2121
#chown quagga:quagga $BASE_DIR/$NODE_NAME
2222

23-
$FRR_PATH/zebra -f $PWD/$BASE_DIR/$NODE_NAME/zebra.conf -d -z $PWD/$BASE_DIR/$NODE_NAME/zebra.sock -i $PWD/$BASE_DIR/$NODE_NAME/zebra.pid
23+
$FRR_PATH/zebra -f "$PWD"/$BASE_DIR/$NODE_NAME/zebra.conf -d -z "$PWD"/$BASE_DIR/$NODE_NAME/zebra.sock -i "$PWD"/$BASE_DIR/$NODE_NAME/zebra.pid
2424

2525
sleep 1
2626

27-
$FRR_PATH/ospfd -f $PWD/$BASE_DIR/$NODE_NAME/ospfd.conf -d -z $PWD/$BASE_DIR/$NODE_NAME/zebra.sock -i $PWD/$BASE_DIR/$NODE_NAME/ospfd.pid
27+
$FRR_PATH/ospfd -f "$PWD"/$BASE_DIR/$NODE_NAME/ospfd.conf -d -z "$PWD"/$BASE_DIR/$NODE_NAME/zebra.sock -i "$PWD"/$BASE_DIR/$NODE_NAME/ospfd.pid

nets/3routers/ospf3r.py

Lines changed: 53 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,27 @@
11
#!/usr/bin/python
22

3-
import os
3+
# pylint: disable=missing-module-docstring
4+
# pylint: disable=missing-function-docstring
5+
# pylint: disable=missing-class-docstring
46

7+
import os
58
import shutil
6-
from mininet.topo import Topo
7-
from mininet.node import Host
8-
from mininet.net import Mininet
9+
910
from mininet.cli import CLI
10-
from mininet.util import dumpNodeConnections
1111
from mininet.link import Link
1212
from mininet.log import setLogLevel
13+
from mininet.net import Mininet
14+
# from mininet.topo import Topo
15+
from mininet.node import Host
16+
from mininet.util import dumpNodeConnections
1317

14-
#BASEDIR = "/home/user/mytests/ospf3routers/nodeconf/"
18+
# BASEDIR = "/home/user/mytests/ospf3routers/nodeconf/"
1519
BASEDIR = os.getcwd()+"/nodeconf/"
1620
OUTPUT_PID_TABLE_FILE = "/tmp/pid_table_file.txt"
1721

1822
PRIVDIR = '/var/priv'
1923

24+
2025
class BaseNode(Host):
2126

2227
def __init__(self, name, *args, **kwargs):
@@ -25,27 +30,29 @@ def __init__(self, name, *args, **kwargs):
2530
self.dir = "/tmp/%s" % name
2631
self.nets = []
2732
if not os.path.exists(self.dir):
28-
os.makedirs(self.dir)
33+
os.makedirs(self.dir)
2934

3035
def config(self, **kwargs):
36+
# pylint: disable=arguments-differ
37+
3138
# Init steps
3239
Host.config(self, **kwargs)
3340
# Iterate over the interfaces
34-
first = True
41+
# first = True
3542
for intf in self.intfs.values():
3643
# Remove any configured address
37-
self.cmd('ifconfig %s 0' %intf.name)
44+
self.cmd('ifconfig %s 0' % intf.name)
3845
# # For the first one, let's configure the mgmt address
3946
# if first:
4047
# first = False
4148
# self.cmd('ip a a %s dev %s' %(kwargs['mgmtip'], intf.name))
42-
#let's write the hostname in /var/mininet/hostname
49+
# let's write the hostname in /var/mininet/hostname
4350
self.cmd("echo '" + self.name + "' > "+PRIVDIR+"/hostname")
44-
if os.path.isfile(BASEDIR+self.name+"/start.sh") :
45-
self.cmd('source %s' %BASEDIR+self.name+"/start.sh")
51+
if os.path.isfile(BASEDIR+self.name+"/start.sh"):
52+
self.cmd('source %s' % BASEDIR+self.name+"/start.sh")
4653

4754
def cleanup(self):
48-
def remove_if_exists (filename):
55+
def remove_if_exists(filename):
4956
if os.path.exists(filename):
5057
os.remove(filename)
5158

@@ -86,78 +93,80 @@ def __init__(self, name, *args, **kwargs):
8693

8794
# the add_link function creates a link and assigns the interface names
8895
# as node1-node2 and node2-node1
89-
def add_link (node1, node2):
96+
97+
98+
def add_link(node1, node2):
9099
Link(node1, node2, intfName1=node1.name+'-'+node2.name,
91-
intfName2=node2.name+'-'+node1.name)
100+
intfName2=node2.name+'-'+node1.name)
101+
92102

93103
def create_topo(my_net):
104+
# pylint: disable=invalid-name
94105
h1 = my_net.addHost(name='h1', cls=BaseNode)
95106
h2 = my_net.addHost(name='h2', cls=BaseNode)
96107
h3 = my_net.addHost(name='h3', cls=BaseNode)
97108
r1 = my_net.addHost(name='r1', cls=Router)
98109
r2 = my_net.addHost(name='r2', cls=Router)
99110
r3 = my_net.addHost(name='r3', cls=Router)
100111

101-
#note that if the interface names are not provided,
102-
#the order of adding link will determine the
103-
#naming of the interfaces (e.g. on r1: r1-eth0, r1-eth1, r1-eth2...)
112+
# note that if the interface names are not provided,
113+
# the order of adding link will determine the
114+
# naming of the interfaces (e.g. on r1: r1-eth0, r1-eth1, r1-eth2...)
104115
# it is possible to provide names as follows
105116
# Link(h1, r1, intfName1='h1-eth0', intfName2='r1-eth0')
106117
# the add_link function creates a link and assigns the interface names
107118
# as node1-node2 and node2-node1
108119

109-
#Link(h1, r1, intfName1='h1-r1', intfName2='r1-h1')
110-
#Link(h2, r2, intfName1='h2-r2', intfName2='r2-h2')
111-
#Link(h3, r3, intfName1='h3-r3', intfName2='r3-h3')
112-
add_link(h1,r1)
113-
add_link(h2,r2)
114-
add_link(h3,r3)
120+
# Link(h1, r1, intfName1='h1-r1', intfName2='r1-h1')
121+
# Link(h2, r2, intfName1='h2-r2', intfName2='r2-h2')
122+
# Link(h3, r3, intfName1='h3-r3', intfName2='r3-h3')
123+
add_link(h1, r1)
124+
add_link(h2, r2)
125+
add_link(h3, r3)
115126

116-
add_link(r1,r2)
117-
add_link(r1,r3)
118-
add_link(r2,r3)
127+
add_link(r1, r2)
128+
add_link(r1, r3)
129+
add_link(r2, r3)
119130

120131

121-
def stopAll():
132+
def stop_all():
122133
# Clean Mininet emulation environment
123134
os.system('sudo mn -c')
124135
# Kill all the started daemons
125136
os.system('sudo killall sshd zebra ospfd')
126137

127-
def extractHostPid (dumpline):
138+
139+
def extract_host_pid(dumpline):
128140
temp = dumpline[dumpline.find('pid=')+4:]
129-
return int(temp [:len(temp)-2])
141+
return int(temp[:len(temp)-2])
130142

131143

132-
133-
def simpleTest():
144+
def simple_test():
134145
"Create and test a simple network"
135146

136-
#topo = RoutersTopo()
137-
#net = Mininet(topo=topo, build=False, controller=None)
147+
# topo = RoutersTopo()
148+
# net = Mininet(topo=topo, build=False, controller=None)
138149
net = Mininet(topo=None, build=False, controller=None)
139150
create_topo(net)
140151

141152
net.build()
142153
net.start()
143154

144-
145155
print("Dumping host connections")
146156
dumpNodeConnections(net.hosts)
147-
#print "Testing network connectivity"
148-
#net.pingAll()
157+
# print "Testing network connectivity"
158+
# net.pingAll()
149159

150-
with open(OUTPUT_PID_TABLE_FILE,"w") as file:
160+
with open(OUTPUT_PID_TABLE_FILE, "w") as file:
151161
for host in net.hosts:
152-
file.write("%s %d\n" % (host, extractHostPid( repr(host) )) )
153-
154-
CLI( net )
155-
net.stop()
156-
stopAll()
162+
file.write("%s %d\n" % (host, extract_host_pid(repr(host))))
157163

164+
CLI(net)
165+
net.stop()
166+
stop_all()
158167

159168

160169
if __name__ == '__main__':
161170
# Tell mininet to print useful information
162171
setLogLevel('info')
163-
simpleTest()
172+
simple_test()

nets/8r-1c-in-band-isis/README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,6 @@ Currently IPv6 forwarding is not explicitly enabled in start.sh, we have to conf
273273
274274
Example of configuration of start.sh
275275
276-
BASE_DIR=/home/user/Progetto/1920-srv6-tutorial/nets/8routers-isis-ipv6/nodeconf
277276
NODE_NAME=h11
278277
GW_NAME=r1
279278
IF_NAME=$NODE_NAME-$GW_NAME

0 commit comments

Comments
 (0)