[P4-dev] Thrift Connection failure while running p4 program in a container

aditya dogra dogra.aditya at gmail.com
Sat Nov 4 08:38:50 EDT 2017


Thanks a lot Antonin for your help. We were able to find out what was
causing this failure. It was not happening because of the thrift version
mismatch .
Its happening because in the LXC container , python api's getaddrinfo fails
for localhost with ""gaierror: [Errno -2] Name or service not known".




Regards,
Aditya Dogra
"When the going gets tough, the tough get going"

On Sat, Nov 4, 2017 at 1:30 AM, Antonin Bas <antonin at barefootnetworks.com>
wrote:

> No you don't need to rebuild bmv2.
> Which version of the Thrift Python package are you using. Please make sure
> that the 2 versions are the same (Thrift library and Thrift Python package).
> I suggest you try moving the transport.open() call (
> https://github.com/p4lang/behavioral-model/blob/master/
> tools/bmpy_utils.py#L103) out of the try / except block. Then at least
> you will get a traceback and you will see where the exception is being
> raised.
>
> On Thu, Nov 2, 2017 at 6:03 PM, aditya dogra <dogra.aditya at gmail.com>
> wrote:
>
>> Thanks Antonin . Do i need to recompile behavioral model ? Because it
>> didnt give me better error message
>>
>>
>>
>> osboxes at osboxes:~/ioam/iOAM/scripts/vpp_sandbox$* sudo lxc-attach -n S1*
>>
>> bash-4.3# *simple_switch_CLI --json
>> /home/osboxes/p4git/p4_tutorials/tutorials/my_exercises/ipv6_examples/ioam/build/ioam.p4.json
>> --thrift-port 9090*
>>
>> *No handlers could be found for logger "thrift.transport.TSocket"*
>>
>> *Could not connect to thrift client on port 9090*
>>
>> Make sure the switch is running and that you have the right port
>>
>> bash-4.3# *more
>> ./home/osboxes/p4git/behavioral-model/tools/bmpy_utils.py*
>>
>> #!/usr/bin/env python
>>
>>
>>
>> # Copyright 2013-present Barefoot Networks, Inc.
>>
>> #
>>
>> # Licensed under the Apache License, Version 2.0 (the "License");
>>
>> # you may not use this file except in compliance with the License.
>>
>> # You may obtain a copy of the License at
>>
>> #
>>
>> #   http://www.apache.org/licenses/LICENSE-2.0
>>
>> #
>>
>> # Unless required by applicable law or agreed to in writing, software
>>
>> # distributed under the License is distributed on an "AS IS" BASIS,
>>
>> # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
>>
>> # See the License for the specific language governing permissions and
>>
>> # limitations under the License.
>>
>> #
>>
>>
>>
>> #
>>
>> # Antonin Bas (antonin at barefootnetworks.com)
>>
>> #
>>
>> #
>>
>>
>>
>> import sys
>>
>> import md5
>>
>>
>>
>> from thrift import Thrift
>>
>> from thrift.transport import TSocket
>>
>> from thrift.transport import TTransport
>>
>> from thrift.protocol import TBinaryProtocol
>>
>> from thrift.protocol import TMultiplexedProtocol
>>
>> *import logging*
>>
>> *logging.basicConfig()*
>>
>>
>>
>> def check_JSON_md5(client, json_src, out=sys.stdout):
>>
>>     with open(json_src, 'r') as f:
>>
>>         m = md5.new()
>>
>>         for L in f:
>>
>>             m.update(L)
>>
>>         md5sum = m.digest()
>>
>>
>>
>> bash-4.3# *more
>> ./home/osboxes/p4git/p4factory/submodules/bm/tools/bmpy_utils.py*
>>
>> #!/usr/bin/env python
>>
>>
>>
>> # Copyright 2013-present Barefoot Networks, Inc.
>>
>> #
>>
>> # Licensed under the Apache License, Version 2.0 (the "License");
>>
>> # you may not use this file except in compliance with the License.
>>
>> # You may obtain a copy of the License at
>>
>> #
>>
>> #   http://www.apache.org/licenses/LICENSE-2.0
>>
>> #
>>
>> # Unless required by applicable law or agreed to in writing, software
>>
>> # distributed under the License is distributed on an "AS IS" BASIS,
>>
>> # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
>>
>> # See the License for the specific language governing permissions and
>>
>> # limitations under the License.
>>
>> #
>>
>>
>>
>> #
>>
>> # Antonin Bas (antonin at barefootnetworks.com)
>>
>> #
>>
>> #
>>
>>
>>
>> import sys
>>
>> import md5
>>
>>
>>
>> from thrift import Thrift
>>
>> from thrift.transport import TSocket
>>
>> from thrift.transport import TTransport
>>
>> from thrift.protocol import TBinaryProtocol
>>
>> from thrift.protocol import TMultiplexedProtocol
>>
>> *import logging*
>>
>> *logging.basicConfig()*
>>
>>
>>
>> def check_JSON_md5(client, json_src, out=sys.stdout):
>>
>>     with open(json_src, 'r') as f:
>>
>>
>>
>> bash-4.3# netstat -anp
>>
>> Active Internet connections (servers and established)
>>
>> Proto Recv-Q Send-Q Local Address           Foreign Address         State
>> PID/Program name
>>
>> *tcp6       0      0 :::9090                 :::*
>> LISTEN      35/simple_switch*
>>
>> Active UNIX domain sockets (servers and established)
>>
>> Proto RefCnt Flags       Type       State         I-Node   PID/Program
>> name    Path
>>
>> unix  2      [ ACC ]     STREAM     LISTENING     31758    1/init
>> /run/systemd/journal/stdout
>>
>> unix  3      [ ]         DGRAM                    31761    1/init
>> /run/systemd/journal/socket
>>
>> unix  2      [ ]         DGRAM                    31772    1/init
>> /run/systemd/journal/dev-log
>>
>> unix  3      [ ]         DGRAM                    31100    1/init
>> /run/systemd/notify
>>
>> unix  2      [ ACC ]     STREAM     LISTENING     31102    1/init
>> /run/systemd/private
>>
>> unix  2      [ ACC ]     STREAM     LISTENING     31343    1/init
>> /var/run/dbus/system_bus_socket
>>
>> unix  2      [ ACC ]     STREAM     LISTENING     32268
>> 35/simple_switch    /tmp/bm-0-log.ipc
>>
>> unix  2      [ ACC ]     STREAM     LISTENING     32271
>> 35/simple_switch    /tmp/bmv2-0-notifications.ipc
>>
>> unix  2      [ ]         DGRAM                    31225    21/systemd-journald
>>
>>
>> unix  3      [ ]         STREAM     CONNECTED     31348    1/init
>>
>>
>> unix  3      [ ]         STREAM     CONNECTING    0        -
>> /var/run/dbus/system_bus_socket
>>
>> unix  3      [ ]         STREAM     CONNECTED     33065
>> 35/simple_switch
>>
>> unix  2      [ ]         DGRAM                    30322    1/init
>>
>>
>> unix  3      [ ]         STREAM     CONNECTED     33064
>> 35/simple_switch
>>
>> unix  2      [ ]         STREAM     CONNECTING    0        -
>> /var/run/dbus/system_bus_socket
>>
>> bash-4.3#
>>
>> Regards,
>> Aditya Dogra
>> "When the going gets tough, the tough get going"
>>
>> On Fri, Nov 3, 2017 at 12:15 AM, Antonin Bas <
>> antonin at barefootnetworks.com> wrote:
>>
>>> Hi,
>>>
>>> I suspect an incompatibility between the Thrift Python module version
>>> and the Thrift library version.
>>> I suggest you try adding the following lines here:
>>> https://github.com/p4lang/behavioral-model/blob/master
>>> /tools/bmpy_utils.py#L31
>>> import logging
>>> logging.basicConfig()
>>>
>>> Then try running the CLI again. Hopefully Thrift will give you a better
>>> error message.
>>>
>>> On Wed, Nov 1, 2017 at 10:22 PM, aditya dogra <dogra.aditya at gmail.com>
>>> wrote:
>>>
>>>> Hi ,
>>>>      We are trying to run a p4 program in a linux container. However we
>>>> are not able to connect to the thrift server after starting the
>>>> simple_switch program within the container.
>>>>
>>>> bash-4.3# *simple_switch -i 1 at l_S11 -i 2 at l_S12 --pcap --thrift-port
>>>> 9090 --nanolog ipc:///tmp/bm-0-log.ipc ioam.p4.json --log-console
>>>> –debugger  **<== Started Simple switch *
>>>>
>>>> Calling target program-options parser
>>>>
>>>> [04:58:57.430] [bmv2] [D] [thread 66] Set default entry for table
>>>> 'ipv6_lpm': NoAction -
>>>>
>>>> [04:58:57.430] [bmv2] [D] [thread 66] Set default entry for table
>>>> 'tbl_add_ioam_option': add_ioam_option -
>>>>
>>>> [04:58:57.430] [bmv2] [D] [thread 66] Set default entry for table
>>>> 'ioam_trace': NoAction -
>>>>
>>>> Adding interface l_S11 as port 1
>>>>
>>>> [04:58:57.430] [bmv2] [D] [thread 66] Adding interface l_S11 as port 1
>>>>
>>>> Adding interface l_S12 as port 2
>>>>
>>>> [04:58:57.466] [bmv2] [D] [thread 66] Adding interface l_S12 as port 2
>>>>
>>>> Thrift server was started
>>>>
>>>> [05:00:50.962] [bmv2] [D] [thread 73] [0.0] [cxt 0] Processing packet
>>>> received on port 1
>>>>
>>>> [05:00:50.962] [bmv2] [D] [thread 73] [0.0] [cxt 0] Parser 'parser':
>>>> start
>>>>
>>>> [05:00:50.962] [bmv2] [D] [thread 73] [0.0] [cxt 0] Extracting header
>>>> 'ethernet'
>>>>
>>>> [05:00:50.962] [bmv2] [D] [thread 73] [0.0] [cxt 0] Parser state
>>>> 'start': key is 86dd
>>>>
>>>> [05:00:50.962] [bmv2] [T] [thread 73] [0.0] [cxt 0] Bytes parsed: 14
>>>>
>>>> [05:00:50.962] [bmv2] [D] [thread 73] [0.0] [cxt 0] Extracting header
>>>> 'ipv6'
>>>>
>>>> [05:00:50.962] [bmv2] [D] [thread 73] [0.0] [cxt 0] Parser set: setting
>>>> field 'parser_metadata.ipv6_nextproto' from field 'ipv6.nextHdr' (17)
>>>>
>>>> [05:00:50.962] [bmv2] [D] [thread 73] [0.0] [cxt 0] Parser state
>>>> 'parse_ipv6': key is 11
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> bash-4.3# *nc -zv 0.0.0.0 9090*
>>>>
>>>> *Connection to 0.0.0.0 9090 port [tcp/*] succeeded!*
>>>>
>>>> bash-4.3# netstat -anp
>>>>
>>>> Active Internet connections (servers and established)
>>>>
>>>> Proto Recv-Q Send-Q Local Address           Foreign Address
>>>> State       PID/Program name
>>>>
>>>> tcp        0      0 127.0.0.1:56998         127.0.0.1:9090
>>>> TIME_WAIT   -
>>>>
>>>> *tcp6       0      0 :::9090                 :::*
>>>> LISTEN      66/simple_switch   *
>>>>
>>>> Active UNIX domain sockets (servers and established)
>>>>
>>>> Proto RefCnt Flags       Type       State         I-Node   PID/Program
>>>> name    Path
>>>>
>>>> unix  2      [ ACC ]     STREAM     LISTENING     54502
>>>> 66/simple_switch    /tmp/bm-0-log.ipc
>>>>
>>>> unix  2      [ ACC ]     STREAM     LISTENING     54505
>>>> 66/simple_switch    /tmp/bmv2-0-notifications.ipc
>>>>
>>>> unix  2      [ ACC ]     STREAM     LISTENING     54508
>>>> 66/simple_switch    /tmp/bmv2-0-debug.ipc
>>>>
>>>> unix  3      [ ]         DGRAM                    51810    1/init
>>>> /run/systemd/notify
>>>>
>>>> unix  2      [ ACC ]     STREAM     LISTENING     51812    1/init
>>>> /run/systemd/private
>>>>
>>>> unix  2      [ ACC ]     STREAM     LISTENING     51820    1/init
>>>> /run/systemd/journal/stdout
>>>>
>>>> unix  3      [ ]         DGRAM                    51823    1/init
>>>> /run/systemd/journal/socket
>>>>
>>>> unix  2      [ ]         DGRAM                    51825    1/init
>>>> /run/systemd/journal/dev-log
>>>>
>>>> unix  2      [ ACC ]     STREAM     LISTENING     52023    1/init
>>>> /var/run/dbus/system_bus_socket
>>>>
>>>> unix  3      [ ]         STREAM     CONNECTED     52026    1/init
>>>>
>>>>
>>>> unix  2      [ ]         STREAM     CONNECTING    0        -
>>>> /var/run/dbus/system_bus_socket
>>>>
>>>> unix  2      [ ]         DGRAM                    52906    17/systemd-journald
>>>>
>>>>
>>>> unix  3      [ ]         STREAM     CONNECTED     56957
>>>> 66/simple_switch
>>>>
>>>> unix  2      [ ]         DGRAM                    51918    1/init
>>>>
>>>>
>>>> unix  3      [ ]         STREAM     CONNECTED     56958
>>>> 66/simple_switch
>>>>
>>>> unix  3      [ ]         STREAM     CONNECTING    0        -
>>>> /var/run/dbus/system_bus_socket
>>>>
>>>> bash-4.3# nc -zv 127.0.0.1 9090
>>>>
>>>> Connection to 127.0.0.1 9090 port [tcp/*] succeeded!
>>>>
>>>> bash-4.3#
>>>>
>>>> bash-4.3# ls /tmp
>>>>
>>>> bm-0-log.ipc  bmv2-0-debug.ipc bmv2-0-notifications.ipc
>>>>
>>>> /home/osboxes/p4git/behavioral-model/tools
>>>>
>>>> bash-4.3# *python p4dbg.py --socket /tmp/bmv2-0-debug.ipc*
>>>>
>>>> No handlers could be found for logger "thrift.transport.TSocket"
>>>>
>>>> *Could not connect to thrift client on port 9090*
>>>>
>>>> *Make sure the switch is running and that you have the right port*
>>>>
>>>> bash-4.3#
>>>>
>>>>
>>>>
>>>> bash-4.3# *simple_switch_CLI --json
>>>> /home/osboxes/p4git/p4_tutorials/tutorials/my_exercises/ipv6_examples/ioam/build/ioam.p4.json
>>>> --thrift-port 9090*
>>>>
>>>> No handlers could be found for logger "thrift.transport.TSocket"
>>>>
>>>> *Could not connect to thrift client on port 9090*
>>>>
>>>> *Make sure the switch is running and that you have the right port*
>>>>
>>>> bash-4.3#
>>>>
>>>> bash-4.3# simple_switch_CLI --json /home/osboxes/p4git/p4_tutoria
>>>> ls/tutorials/my_exercises/ipv6_examples/ioam/build/ioam.p4.json
>>>> --thrift-port 56998
>>>>
>>>> No handlers could be found for logger "thrift.transport.TSocket"
>>>>
>>>> Could not connect to thrift client on port 56998
>>>>
>>>> Make sure the switch is running and that you have the right port
>>>>
>>>> bash-4.3#
>>>>
>>>>
>>>>
>>>> Are there any debugs which we can look to find out the reasons for such
>>>> failures ?
>>>>
>>>> *Same program and same steps work perfectly fine when we run it outside
>>>> the container.*
>>>>
>>>> Regards,
>>>> Aditya Dogra
>>>> "When the going gets tough, the tough get going"
>>>>
>>>> _______________________________________________
>>>> P4-dev mailing list
>>>> P4-dev at lists.p4.org
>>>> http://lists.p4.org/mailman/listinfo/p4-dev_lists.p4.org
>>>>
>>>
>>>
>>>
>>> --
>>> Antonin
>>>
>>
>>
>
>
> --
> Antonin
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.p4.org/pipermail/p4-dev_lists.p4.org/attachments/20171104/bb6c7b33/attachment-0002.html>


More information about the P4-dev mailing list