1
0
mirror of https://github.com/CumulusNetworks/ifupdown2.git synced 2024-05-06 15:54:50 +00:00

20 Commits

Author SHA1 Message Date
a61d1777cd nlmanager: Provide option to prevent color output
Ticket: CM-7361
Reviewed By: CCR-
Testing Done: Tested with clag

Certain loggers, most notably the syslog, don't allow non-printable characters
in their output, and so they convert them to a string of printable characters.
For example, the newline character is converted to #012. This results in output
that looks like this:

2016-08-29T18:50:46.263178+00:00 act-5712-08 clagd[21539]: RXed RTM_NEWNEIGH,
length 68, seq 0, pid 0, flags 0x0#012#012  #033[91mNetlink Header#033[0m#012
1: #033[91m0x44000000#033[0m  D...  Length 0x00000044 (68)#012   2:
#033[91m0x1c000000#033[0m  ....  Type 0x001c (28 - RTM_NEWNEIGH), Flags 0x0000
()#012   3: #033[91m0x00000000#033[0m  ....  Sequence Number 0x00000000 (0)#012
4: #033[91m0x00000000#033[0m  ....  Process ID 0x00000000 (0)#012
#033[93mService Header#033[0m#012   5: #033[93m0x07000000#033[0m  ....  Family
0x07 (7)#012   6: #033[93m0x29010000#033[0m  )...  Interface Index 0x00000129
(297)#012   7: #033[93m0x02000000#033[0m  ....  State 0x0002 (2), Flags 0x00,
Type 0x0000 (0)#012  Attributes#012   8: #033[92m0x0a000200#033[0m  ....  Length
0x000a (10) padded to 12, Type 0x0002 (2) NDA_LLADDR#012   9:
#033[92m0x00020000#033[0m  ....  00:02:00:00:00:09#012  10:
#033[92m0x00090000#033[0m  ....  #012  11: #033[94m0x08000900#033[0m  ....
Length 0x0008 (8), Type 0x0009 (9) NDA_MASTER#012  12: #033[94m0x2b010000#033[0m
+...  299#012  13: #033[92m0x14000300#033[0m  ....  Length 0x0014 (20), Type
0x0003 (3) NDA_CACHEINFO#012  14: #033[92m0x00000000#033[0m  ....  0#012  15:
#033[92m0x00000000#033[0m  ....  0#012  16: #033[92m0x00000000#033[0m  ....
0#012  17: #033[92m0x00000000#033[0m  ....  0#012#012Attributes Summary#012{'(
2) NDA_LLADDR': '00:02:00:00:00:09',#012 '( 3) NDA_CACHEINFO': (0, 0, 0, 0),#012
'( 9) NDA_MASTER': 299}

which is rather hard to interpret. So this patch modifes the nlpacket debug
output so that the user can specify whether or not color output should be used
by including an extra, optional parameter when instantiating a NetlinkPacket
object. The default is for color output, just like before this patch. But if
color output is not desired, then no VT100 control sequences will be output. Nor
will there be any newline characters embedded in the output.

The NetlinkManagerWithListener and NetlinkManager classes were also modified to
add the same optional use_color attribute, which defaults to True. Thus when
class members which instantiate NetlinkPacket objects are created the
appropriate value for the use_color attribute will be applied.

I also noticed that the default pid_offset of the NetlinkListener class was 2,
when it should have been 1. So I fixed that too.
2016-11-23 04:54:38 +01:00
9f25ff0dbd nlmanager: Support new attribute types
Ticket: CM-7361
Reviewed By: CCR-5124
Testing Done: Tested with clag

CLAG requires some additional nlmanager functionality. Firstly, different
threads in CLAG with the same PID may instantiate NetlinkManager objects. This
currently assigned each the same pid value, which causes issues. So an optional
pid_offset parameter is added which is added to the PID when instantiating a
NetlinkManager object. This allows multiple threads in the same PID to be able
to have distinct identifiers. If a pid_offset is supplied, it should be 2 or
greater, since 0 and 1 are used by the NetlinkManagerWithListener.

Added two new attribute classes: FourByteList and TwoByteValue. Added an encode
function for the IPAddress attribute, and corrected some length errors in the
MACAddress attribute.

The Neighbor class got actual values for the CacheInfo, VLAN, VNI, IfIndex, and
Master attributes. The "Self" and "Master" flag values were added.

Also added the "family" parameter to the constructor for all attribute classes.
This eliminates the special-casing required for certain attribute's
instantiation.
2016-11-23 04:54:38 +01:00
19c9569911 nlmanager: fixing error messages when receiving NLMSG_ERROR
Ticket: CM-12596
Reviewed By: Roopa, Daniel W
Testing Done:

before this patch:

$ cat /etc/network/interfaces
auto tapppppppppppp0.42
iface tapppppppppppp0.42
$
$ ifreload -a
warning: /etc/network/interfaces: line8: tapppppppppppp0.42: interface name too long
error: netlink: tapppppppppppp0: cannot create vlan 42: Operation failed with 'None' (RXed  NLMSG_ERROR, pid 3346, seq 6, 108 bytes)
$

after:

$ ifreload -a
warning: /etc/network/interfaces: line8: tapppppppppppp0.42: interface name too long
error: netlink: tapppppppppppp0: cannot create vlan 42: Operation failed with 'Numerical result out of range'
$

Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
2016-08-25 14:57:21 -07:00
26d1e82b2f nlmanager: support for bridge vlan and show commands
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
Reviewed-by:   julien@cumulusnetworks.com

Ticket: CM-12199

Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
2016-08-25 14:39:36 -07:00
cb80e1d386 nlmanager: changing log level (info->debug) for TXed messages
Ticket: CM-11857
Reviewed By: Roopa, Daniel W
Testing Done:

Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
2016-08-24 10:19:55 -07:00
76352436e7 rdnbrd "Interrupted system call" traceback in nlmanager
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
Reviewed-by:   roopa@cumulusnetworks.com

Ticket: CM-12487
2016-08-24 10:19:55 -07:00
cee2e13ffb nlmanager: rdnbrd "Interrupted system call" traceback in nlmanager
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
Reviewed-by:   roopa@cumulusnetworks.com
Ticket: CM-12487

Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
2016-08-24 10:19:55 -07:00
4e979b1bcf nlpacket: add new attribute: AttributeStringInterfaceName with length check
Ticket: CM-12302
Reviewed By: Daniel, Roopa, Nikhil G
Testing Done: ifupdown2 smoke test

With this pretty straight forward, we introduce a new Attribute in nlmanager,
so that we have single check and no code redundancy for ifname length. This
also prevent loosing time sending a netlink packet for an known error.

Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
2016-08-24 10:19:54 -07:00
2e04b8c01c nlmanager: changing messages logged and raised when RXed NLMSG_ERROR
Ticket: None
Reviewed By: Roopa, Nikhil G, Daniel
Testing Done: ifupdown2 smokes

The message logged and the exception raised by nlmanager, when receiving
an NLMSG_ERROR packet from the kernel, wasn't super explicit plus if the
error wasn't a netlink related failure we didn't provide any information
Now we use strerror with the provided error code to generate a nice msg.

Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
2016-08-24 10:19:53 -07:00
c268fccf3f nlmanager: wait for ACK after single packet operation
Ticket: None
Reviewed By: Roopa, Nikhil G, Daniel
Testing Done: ifupdown2 smoke

We used to have these checks in the old rtnetlink python library.
They were missing in python-nlmanager this was a big regression for
ifupdown2.

Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
2016-08-24 10:19:53 -07:00
81d9736d03 nlmanager: changing log level to debug for RXed messages
Ticket: CM-11857
Reviewed By: Daniel, Roopa
Testing Done:

Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
2016-07-18 10:45:45 +01:00
6080ea9f9c importing: "nlmanager: changing log level info->debug for TXed messages"
Ticket: CM-11708
Reviewed By: Roopa, Daniel
Testing Done:

Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
2016-07-12 00:39:44 +01:00
5fd9723752 importing: "nlmanager: removing IFLA_VXLAN_LINK attribute from packet when creating vxlan"
Ticket:
Reviewed By: Roopa, Daniel
Testing Done:

Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
2016-07-12 00:34:56 +01:00
f1bec02e27 nlmanager: nlpacket: vxlan dstport config incorrect
Ticket: CM-11735
Reviewed By: Roopa, Daniel
Testing Done: creating a vxlan with ifupdown then checking the dstport with
ip -d link show $vlxanName

When creating a vxlan nlmanager didn't re-order/byte swap the dstport value
to little endian

46354 instead of 4789

Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
2016-07-10 03:40:25 +01:00
3696839d82 python-nlamanger: importing vxlan creation support commit
Ticket: CM-8035
Reviewed By: CCR-4896
Testing Done: ifupdown smoke, -t vxlan tests

julien@hydra-01:~$ time runtests.sh -d cel-redxp-06 -r result_vxlan_all.txt -f . -T vxlan_all.log -l INFO -k $VM_BASE_KERNEL -i $VM_BASE_IMG $TESTS_HOME/tests/ -t vxlan

Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
2016-07-05 14:40:19 +02:00
26e7207b6b nlmanager: nlpacket: throw an error if the user of nlmanager tries to encode an attribute that we haven't added an encode() method for
+ adding one byte attribute class for protodown operations.

Ticket: CM-11581
Reviewed By: CCR-4721
Testing Done: Smoke + custom interface file with clag bond that requires protodown.

- nlmanager will now throw an exception if a user is trying to use the default
attribute class when in fact he should use a more specific attribute class.

- The protodown implementation needed to use a one byte attribute to set the protodown state

Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
2016-06-27 00:24:18 +01:00
5b7f45794f 'this is an ACK' message should be log.debug() not log.info()
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
Reviewed-by: Julien Fortin <julien@cumulusnetworks.com>
2016-06-24 00:51:26 +01:00
ea2bf79dcf Attribute 20 is not defined in Route.attribute_to_class
Ticket: CM-11515

Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
Reviewed-by: Julien Fortin <julien@cumulusnetworks.com>
2016-06-24 00:48:13 +01:00
d8a846b8ae Remove dependancy on tabulate
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
Reviewed-by:   roopa@cumulusnetworks.com
2016-06-21 22:03:10 +01:00
198ded6a35 Import python-nlmanager mirror copy
Ticket: CM-7360
Reviewed By: CCR-4721
Testing Done: smoke / testifreload / Tested on amd64 platform (by Sam)

For now, we use a mirror copy of nlmanager sources to make sure we don't
depend on it as an external package

Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
2016-06-16 03:37:35 +01:00