[P4-dev] P4Runtime with bmv2 support

cs.lev cs.lev at gmx.com
Tue Jul 17 11:21:54 EDT 2018


Dear all,

I would like to have proper P4Runtime support on a bare-metal server,
with all its python bindings to write my own controllers.

I have run into the following issue during configuring and compiling
related libraries.

First of all, I found there is a cyclic dependency between bmv2 and PI
(but correct me if I am wrong), as bmv2 can be compiled with PI support
(--with-pi) which needs the PI libraries to be installed in order to
compile afterwards the simple_switch_grpc binary.
However, to support bmv2 in PI, during its installation, it requires
bmv2 and its libraries.

As a workaround, first I compiled PI without bmv2 support, then
compiled bmv2 with PI support, and finally I recompiled PI with bmv2
support.
Everything seemed to be OK, as compilation ended without errors and
simple_switch_grpc could have been run.

After trying to test (a modified version of the) p4runtime example
(originally tailored to the mininet environment) from p4lang/tutorial, 
the python based controller has complained about missing modules.
After a lot of googling, debugging, and comparing ENV variables of the
p4tutorial’s VM and my bare metal installation, I have found that the
libraries the python modules are looking for should be in
/usr/local/lib/python2.7/dist-packages/p4/.

However, the PI installation on the bare metal put all libraries into
/usr/local/lib/python2.7/dist-packages/p4/v1, 
even though the configure parameter --with-bmv2 should have indicated
to the compilation process to not put the corresponding libraries in
such a subdirectory (v1).

In the beginning, it seemed a good idea to do the following:


$ cp /usr/local/lib/python2.7/dist-packages/p4/v1/*
/usr/local/lib/python2.7/dist-packages/p4/


$ cp  /usr/local/lib/python2.7/dist-packages/p4/config/v1/*
/usr/local/lib/python2.7/dist-packages/p4/config/
Then, the controller application was now complaining about missing
modules.
So, it indeed seemed to be a good workaround...


BUT, (if you are still with me :)), the interesting parts started to
show up.
The controller could connect to the switch and even the
readTableRules(p4info_helper,switch) function could have been called
and returned without errors.

At this point, I still believed that everything is working, however
when I tried to insert flow rules into my switch, the controller raised
the following error:
  File "controller.py", line 86, in main
    output_port='0')
  File "controller.py", line 23, in addIPforwardRule
    "port": 1,
  File
"/home/csikor/p4/p4_vlan/p4runtime_controller/p4runtime_lib/helper.py",
line 173, in buildTableEntry
    for match_field_name, value in match_fields.iteritems()
  File
"/home/csikor/p4/p4_vlan/p4runtime_controller/p4runtime_lib/helper.py",
line 100, in get_match_field_pb
    if match_type == p4info_pb2.MatchField.VALID:
AttributeError: type object 'MatchField' has no attribute 'VALID'


The rule inserting source code had no issues in the mininet
environment, but for a comprehensive view I include the relevant part
of it below: 
def addIPforwardRule(p4info_helper, sw):
table_entry = p4info_helper.buildTableEntry(
		table_name="MyIngress.ipv4_lpm",
		match_fields={
			"hdr.ipv4.dstAddr": ("10.0.0.1", 32)
		},
		action_name="MyIngress.ipv4_forward",
		action_params={
			"port": 1
		})
	sw.WriteTableEntry(table_entry)


Later on, I have found out that in contrast to other python modules,
the p4info_pb2 library that I have used (copied from
/usr/local/lib/python2.7/dist-packages/p4/config/v1) is not the same as
it was in the p4lang/tutorial's VM's python modules, which of course is
somewhat expected.


In order to do a workaround  again, as a last resort I have copied all
the python libraries for P4runtime from the
VM's  /usr/local/lib/python2.7/dist-packages/p4/ directory to the same
place at my bare metal server, but now I get a UNIMPLEMENTED error :)

  File "controller.py", line 95, in
main    s.SetForwardingPipelineConfig(p4info=p4info_helper.p4info,
bmv2_json_file_path=bmv2_file_path)    File
"/home/csikor/p4/p4_vlan/p4runtime_controller/p4runtime_lib/switch.py",
line 45, in
SetForwardingPipelineConfig    self.client_stub.SetForwardingPipelineCo
nfig(request)  
  File "/usr/local/lib/python2.7/dist-packages/grpc/_channel.py", line
492, in __call__    return _end_unary_response_blocking(state, call,
False, deadline)  
  File "/usr/local/lib/python2.7/dist-packages/grpc/_channel.py", line
440, in _end_unary_response_blocking    


  raise _Rendezvous(state, None, None,
deadline)grpc._channel._Rendezvous: <_Rendezvous of RPC that terminated
with (StatusCode.UNIMPLEMENTED, )>
I guess some of the installation steps should be revisited, but can
someone explain me in which order and how should I proceed with the
installation of the libraries to have the same environment as the VM
has?Or what else can I do?
Thank you for considering my request.
BR,Levi















-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.p4.org/pipermail/p4-dev_lists.p4.org/attachments/20180717/f0155496/attachment.html>


More information about the P4-dev mailing list