You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$ sudo ip tunnel add greif mode gre remote 189.254.111.111 local 189.254.222.222 ttl 255
This operation creates interface kind="gre" plus an interface kind="erspan". When we get attributes for the latter, result contains IFLA_LINKINFO -> IFLA_INFO_DATA which is a string:
>>> [(el.get_attr("IFLA_IFNAME"), el.get_nested("IFLA_LINKINFO", "IFLA_INFO_KIND"), el.get_nested("IFLA_LINKINFO", "IFLA_INFO_DATA")) for el in IPRoute().get_links() if el.get_nested("IFLA_LINKINFO", "IFLA_INFO_KIND") == "erspan"]
[('erspan0', 'erspan', '05:00:16:00:01:00:00:00:08:00:15:00:00:00:00:00:08:00:01:00:00:00:00:00:06:00:02:00:00:00:00:00:06:00:03:00:20:00:00:00:08:00:04:00:00:00:00:00:08:00:05:00:00:00:00:00:08:00:06:00:00:00:00:00:08:00:07:00:00:00:00:00:05:00:08:00:00:00:00:00:05:00:09:00:00:00:00:00:05:00:0a:00:00:00:00:00:08:00:14:00:00:00:00:00:06:00:0e:00:00:00:00:00:06:00:10:00:00:00:00:00:06:00:11:00:00:00:00:00:06:00:0f:00:00:00:00:00:05:00:13:00:00:00:00:00')]
>>>
For other types of interfaces, IFLA_INFO_DATA contains other useful nested attributes, so I want to be able to use, for instance,
but when there is an erspan interface in the list, get_nested crashes:
>>> [(el.get_attr("IFLA_IFNAME"), el.get_nested("IFLA_LINKINFO", "IFLA_INFO_KIND"), el.get_nested("IFLA_LINKINFO", "IFLA_INFO_DATA", "IFLA_SOME_ATTRIBUTE")) for el in IPRoute().get_links() if el.get_nested("IFLA_LINKINFO", "IFLA_INFO_KIND") == "erspan"]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 1, in <listcomp>
File "/usr/lib/python3/dist-packages/pr2modules/netlink/__init__.py", line 1130, in get_nested
pointer = pointer.get_attr(attr)
AttributeError: 'str' object has no attribute 'get_attr'
>>>
I understand that `get_nested()` is supposed to be "safe": never crash, and just return `None` if it cannot access an attribute.
The text was updated successfully, but these errors were encountered:
This operation creates interface kind="gre" plus an interface kind="erspan". When we get attributes for the latter, result contains
IFLA_LINKINFO -> IFLA_INFO_DATA
which is a string:For other types of interfaces,
IFLA_INFO_DATA
contains other useful nested attributes, so I want to be able to use, for instance,but when there is an
erspan
interface in the list,get_nested
crashes:The text was updated successfully, but these errors were encountered: