p4lang / tutorials

P4 language tutorials
Apache License 2.0
1.33k stars 879 forks source link

Using Mininet Host as the P4Runtime Remote Controller Results in GRPC Error #275

Closed burakatalay closed 4 years ago

burakatalay commented 5 years ago

Hi everyone,

I am trying to execute my P4Runtime controller code on the Mininet host. Essentially what I am trying to do is send commands to write table entries on the switch from the Mininet host, or at least trigger the write command from the host. However this results in

gRPC Error: Connect Failed (UNAVAILABLE)

This error occurs during the MasterArbitrationUpdate stage.

I checked the code and the P4Runtime specification. The switch is supposed to have a local GRPC server. If I understood correctly, the "p4runtime_switch.py" file sets up this server with the address 0.0.0.0:50051 as seen here

if self.grpc_port:
            args.append("-- --grpc-server-addr 0.0.0.0:" + str(self.grpc_port))

And on the mycontroller.py file we have the BMV2SwitchConnection, which connects to 127.0.0.1:50051, which is seen here:

s1 = p4runtime_lib.bmv2.Bmv2SwitchConnection(
            name='s1',
            address='127.0.0.1:50051',
            device_id=0,
            proto_dump_file='logs/s1-p4runtime-requests.txt')

So I am able to run mycontroller.py successfully on a separate terminal. In the Mininet CLI, I can execute the command "s1 python controller.py" successfully as well, however the command "h1 python controller.py" fails.

I know that the 127.0.0.1 is the loopback address, and my assumption is that this is the reason I can run the controller code on s1 from the Mininet CLI. My question is what would be the way to run the controller code on h1?

When I try to change the IP address from 0.0.0.0 to something else, I get an error message

P4 switch s1 did not start correctly.

And on s1.log I see the following:

server_chttp2.c:53] {"created":"@1565601338.541072032","description":"No address added out of total 1 resolved","file":"src/core/ext/transport/chttp2/server/chttp2_server.c","file_line":259,"referenced_errors":[{"created":"@1565601338.541058734","description":"Unable to configure socket","fd":11,"file":"src/core/lib/iomgr/tcp_server_utils_posix_common.c","file_line":215,"referenced_errors":[{"created":"@1565601338.541043288","description":"OS Error","errno":99,"file":"src/core/lib/iomgr/tcp_server_utils_posix_common.c","file_line":188,"os_error":"Cannot assign requested address","syscall":"bind"}]}]}

So to sum up, I am trying to run my remote P4Runtime Controller from the Mininet host.

Any help would be appreciated.

Best regards.

Niklas310798 commented 2 years ago

Hi everyone,

although this topic is closed there is no sufficient answer to this. I am now facing the same issue. Is there any chance to create a P4Runtime Connection to the switch from a P4 Host in the same Mininet environment? I am planning to push new or update existing table rules on the switches.

Or maybe is there another/better solution? FYI: I need to send cloned packages to that host that should execute the P4Runtime Controller, that is why I thought of running the code on a P4 Host.

Thanks in advance for your help!

rst0git commented 2 years ago

what would be the way to run the controller code on h1?

Is there any chance to create a P4Runtime Connection to the switch from a P4 Host in the same Mininet environment?

The controller is not intended to run in h1. Mininet is using network namespaces to provide isolation between everything running in h1 and the host network namespace.

You can follow the P4Runtime exercise to learn more about how to create a P4Runtime connection to the switch.

I hope this helps.