chiark / gitweb /
networkd: Add support for bond option.
authorSusant Sahani <susant@redhat.com>
Mon, 9 Mar 2015 09:58:29 +0000 (15:28 +0530)
committerSven Eden <yamakuzure@gmx.net>
Tue, 14 Mar 2017 06:43:13 +0000 (07:43 +0100)
This patch adds configurational support for bond option.

Test conf:

bond.netdev

 ---
[NetDev]
Name=bond1
Kind=bond

[Bond]
ArpAllTargets=all
PrimaryReselect=better
ArpIntervalSec=10s
ArpIpTargets= 192.168.8.102 192.168.8.101 192.168.8.102
 ---

$cat /proc/net/bonding/bond1
Ethernet Channel Bonding Driver: v3.7.1 (April 27, 2011)

Bonding Mode: load balancing (round-robin)
MII Status: up
MII Polling Interval (ms): 0
Up Delay (ms): 0
Down Delay (ms): 0
ARP Polling Interval (ms): 10000
ARP IP target/s (n.n.n.n form): 192.168.8.100, 192.168.8.101, 192.168.8.102

src/libelogind/sd-rtnl/rtnl-types.c
src/libelogind/sd-rtnl/rtnl-types.h

index 455ae28d19387f47fd06b9d8752248403c91a914..3916b0bd67ce2d72f10c743df66b4f6418570d1c 100644 (file)
@@ -90,6 +90,30 @@ static const NLType rtnl_link_info_data_vxlan_types[IFLA_VXLAN_MAX+1] = {
         [IFLA_VXLAN_L3MISS] = { .type = NLA_U8 },
 };
 
+static const NLType rtnl_bond_arp_target_types[BOND_ARP_TARGETS_MAX + 1] = {
+        [BOND_ARP_TARGETS_0]        = { .type = NLA_U32 },
+        [BOND_ARP_TARGETS_1]        = { .type = NLA_U32 },
+        [BOND_ARP_TARGETS_2]        = { .type = NLA_U32 },
+        [BOND_ARP_TARGETS_3]        = { .type = NLA_U32 },
+        [BOND_ARP_TARGETS_4]        = { .type = NLA_U32 },
+        [BOND_ARP_TARGETS_5]        = { .type = NLA_U32 },
+        [BOND_ARP_TARGETS_6]        = { .type = NLA_U32 },
+        [BOND_ARP_TARGETS_7]        = { .type = NLA_U32 },
+        [BOND_ARP_TARGETS_8]        = { .type = NLA_U32 },
+        [BOND_ARP_TARGETS_9]        = { .type = NLA_U32 },
+        [BOND_ARP_TARGETS_10]       = { .type = NLA_U32 },
+        [BOND_ARP_TARGETS_11]       = { .type = NLA_U32 },
+        [BOND_ARP_TARGETS_12]       = { .type = NLA_U32 },
+        [BOND_ARP_TARGETS_13]       = { .type = NLA_U32 },
+        [BOND_ARP_TARGETS_14]       = { .type = NLA_U32 },
+        [BOND_ARP_TARGETS_MAX]      = { .type = NLA_U32 },
+};
+
+static const NLTypeSystem rtnl_bond_arp_type_system = {
+        .max = ELEMENTSOF(rtnl_bond_arp_target_types) - 1,
+        .types = rtnl_bond_arp_target_types,
+};
+
 static const NLType rtnl_link_info_data_bond_types[IFLA_BOND_MAX + 1] = {
         [IFLA_BOND_MODE]                = { .type = NLA_U8 },
         [IFLA_BOND_ACTIVE_SLAVE]        = { .type = NLA_U32 },
@@ -98,7 +122,7 @@ static const NLType rtnl_link_info_data_bond_types[IFLA_BOND_MAX + 1] = {
         [IFLA_BOND_DOWNDELAY]           = { .type = NLA_U32 },
         [IFLA_BOND_USE_CARRIER]         = { .type = NLA_U8 },
         [IFLA_BOND_ARP_INTERVAL]        = { .type = NLA_U32 },
-        [IFLA_BOND_ARP_IP_TARGET]       = { .type = NLA_NESTED },
+        [IFLA_BOND_ARP_IP_TARGET]       = { .type = NLA_NESTED, .type_system = &rtnl_bond_arp_type_system },
         [IFLA_BOND_ARP_VALIDATE]        = { .type = NLA_U32 },
         [IFLA_BOND_ARP_ALL_TARGETS]     = { .type = NLA_U32 },
         [IFLA_BOND_PRIMARY]             = { .type = NLA_U32 },
index 1ab9444987b6e9563188bc6edcd8d3bef7f28b2e..72773eaa66e4a4eb47b3c8655a121c1a242d5531 100644 (file)
@@ -94,3 +94,25 @@ typedef enum NLUnionLinkInfoData {
 
 const char *nl_union_link_info_data_to_string(NLUnionLinkInfoData p) _const_;
 NLUnionLinkInfoData nl_union_link_info_data_from_string(const char *p) _pure_;
+
+/* Maximum ARP IP target defined in kernel */
+#define BOND_MAX_ARP_TARGETS    16
+
+typedef enum BondArpTargets {
+        BOND_ARP_TARGETS_0,
+        BOND_ARP_TARGETS_1,
+        BOND_ARP_TARGETS_2,
+        BOND_ARP_TARGETS_3,
+        BOND_ARP_TARGETS_4,
+        BOND_ARP_TARGETS_5,
+        BOND_ARP_TARGETS_6,
+        BOND_ARP_TARGETS_7,
+        BOND_ARP_TARGETS_8,
+        BOND_ARP_TARGETS_9,
+        BOND_ARP_TARGETS_10,
+        BOND_ARP_TARGETS_11,
+        BOND_ARP_TARGETS_12,
+        BOND_ARP_TARGETS_13,
+        BOND_ARP_TARGETS_14,
+        BOND_ARP_TARGETS_MAX = BOND_MAX_ARP_TARGETS,
+} BondArpTargets;