Skip to content

Commit

Permalink
Use PCI addr in veth alias, fallback to scanning
Browse files Browse the repository at this point in the history
This will be primarily for k8s setup. To test locally

docker exec bess ip link set ens803f2 alias '0000:07:02.0'
docker exec bess ip link set ens803f3 alias '0000:07:02.1'
docker exec bess ./bessctl run spgwu

Signed-off-by: Saikrishna Edupuganti <saikrishna.edupuganti@intel.com>
  • Loading branch information
krsna1729 authored and ajamshed committed Apr 23, 2020
1 parent 0047673 commit 326cf42
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 10 deletions.
33 changes: 23 additions & 10 deletions conf/spgwu.bess
Original file line number Diff line number Diff line change
Expand Up @@ -151,16 +151,29 @@ class Port:
self.init_fastpath(**kwargs)

elif mode == 'dpdk':
# if port list is empty, scan for dpdk_ports first
if not dpdk_ports and scan_dpdk_ports() == False:
print('Registered dpdk ports do not exist.')
sys.exit()
# Initialize DPDK fastpath
fidx = dpdk_ports.get(mac_by_interface(name))
if fidx is None:
raise Exception('Registered port for {} not detected!'.format(name))
kwargs = {"port_id" : fidx, "num_out_q": workers}
self.init_fastpath( **kwargs)
kwargs = None
pci = alias_by_interface(name)
if pci is not None:
kwargs = {"pci": pci, "num_out_q": workers}
try:
self.init_fastpath(**kwargs)
except:
kwargs = None
print('Unable to initialize {} fastpath using alias {},\
falling back to scan'.format(name, pci))
if kwargs is None:
# Fallback to scanning ports
# if port list is empty, scan for dpdk_ports first
if not dpdk_ports and scan_dpdk_ports() == False:
print('Registered dpdk ports do not exist.')
sys.exit()
# Initialize DPDK fastpath
fidx = dpdk_ports.get(mac_by_interface(name))
if fidx is None:
raise Exception(
'Registered port for {} not detected!'.format(name))
kwargs = {"port_id": fidx, "num_out_q": workers}
self.init_fastpath(**kwargs)

# Initialize kernel slowpath port and RX/TX modules
try:
Expand Down
6 changes: 6 additions & 0 deletions conf/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def getpythonpid(process_name):
return proc.info['pid']
return


def get_json_conf(path, dump):
conf = json.loads(open(path).read())
if dump:
Expand All @@ -55,6 +56,11 @@ def ips_by_interface(name):
return [ipobj[0] for ipobj in ipdb.interfaces[name]['ipaddr'].ipv4]


def alias_by_interface(name):
ipdb = IPDB()
return ipdb.interfaces[name]['ifalias']


def mac_by_interface(name):
ipdb = IPDB()
return ipdb.interfaces[name]['address']
Expand Down

0 comments on commit 326cf42

Please sign in to comment.