Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mininet crash when "program" is placed in subdirectory #73

Open
MehTheHedgehog opened this issue Feb 28, 2020 · 0 comments
Open

Mininet crash when "program" is placed in subdirectory #73

MehTheHedgehog opened this issue Feb 28, 2020 · 0 comments

Comments

@MehTheHedgehog
Copy link

MehTheHedgehog commented Feb 28, 2020

Hi everyone,

I've got a problem with running my own package when P4 source file are not placed in package root.
It seems to be issue with p4apprunner.py, which set log file from program section of manifest as is, so single_switch_mininet.py cannot create log file in non existing directory.

Changing p4apprunner.py resolved issue and also work with example packages.

log_file = os.path.join('/var/log', manifest.program_file + '.log')

to

log_file = os.path.join('/var/log', (os.path.split(manifest.program_file)[-1]) + '.log')

Config:

{
  "program": "src/main.p4",
  "language": "p4-14",
  "targets": {
    "debug": {
      "use": "mininet",
      "num-hosts": 2,
      "switch-config": "cfg/p4app.d/sim_config.config"
    }
  }
}

Run output:

Entering build directory.
Extracting package.
> touch /tmp/p4app_logs/p4s.s1.log
> ln -s /tmp/p4app_logs/p4s.s1.log /tmp/p4s.s1.log
Reading package manifest.
> p4c-bm2-ss --p4v 14 -D _BMV2_ -I include/ "src/main.p4" -o "main.json"
> python2 "/scripts/mininet/single_switch_mininet.py" --log-file "/var/log/src/main.p4.log" --cli-message "mininet_message.txt" --num-hosts 2 --switch-config "cfg/p4app.d/sim_config.config" --behavioral-exe "simple_switch" --json "main.json"
Adding host h1
Adding host h2
*** Error setting resource limits. Mininet's performance may be affected.
*** Creating network
*** Adding hosts:
h1 h2 
*** Adding switches:
Traceback (most recent call last):
  File "/scripts/mininet/single_switch_mininet.py", line 137, in <module>
    main()
  File "/scripts/mininet/single_switch_mininet.py", line 88, in main
    controller = None)
  File "build/bdist.linux-x86_64/egg/mininet/net.py", line 173, in __init__
  File "build/bdist.linux-x86_64/egg/mininet/net.py", line 501, in build
  File "build/bdist.linux-x86_64/egg/mininet/net.py", line 482, in buildFromTopo
  File "build/bdist.linux-x86_64/egg/mininet/net.py", line 259, in addSwitch
  File "/scripts/mininet/p4_mininet.py", line 80, in __init__
    self.output = open(self.log_file, 'w')
IOError: [Errno 2] No such file or directory: '/var/log/src/main.p4.log'

This change is in my fork of this repo and can be PR here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant