Skip to contentSkip to conversation

bonding: show NS IPv6 targets in proc master info

PATCH Superseded Hangbin Liu 3 participants 6 messages May 27, 2022 – May 30, 2022

Subsystems (3)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bonding: show NS IPv6 targets in proc master info

When adding bond new parameter ns_targets. I forgot to print this in bond master proc info. After updating, the bond master info will looks like:

ARP IP target/s (n.n.n.n form): 192.168.1.254
NS IPv6 target/s (XX::XX form): 2022::1, 2022::2

Fixes 4e24be018eb9 ("bonding: add new parameter ns_targets")
---
 drivers/net/bonding/bond_procfs.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
drivers/net/bonding/bond_procfs.c +13 -0
index cfe37be42be4..b6c012270e2e 100644
@@ -129,6 +129,19 @@ static void bond_info_show_master(struct seq_file *seq)
 			printed = 1;
 		}
 		seq_printf(seq, "\n");
+
+		printed = 0;
+		seq_printf(seq, "NS IPv6 target/s (xx::xx form):");
+
+		for (i = 0; (i < BOND_MAX_NS_TARGETS); i++) {
+			if (ipv6_addr_any(&bond->params.ns_targets[i]))
+				break;
+			if (printed)
+				seq_printf(seq, ",");
+			seq_printf(seq, " %pI6c", &bond->params.ns_targets[i]);
+			printed = 1;
+		}
+		seq_printf(seq, "\n");
 	}
 
 	if (BOND_MODE(bond) == BOND_MODE_8023AD) {
Signature · 1 line
2.35.1
#1 lore raw
Quoted 2 lines · Hangbin Liu

When adding bond new parameter ns_targets. I forgot to print this in bond master proc info. After updating, the bond master info will looks

                                                               look ---^
Quoted 17 lines

like:

ARP IP target/s (n.n.n.n form): 192.168.1.254
NS IPv6 target/s (XX::XX form): 2022::1, 2022::2

Fixes 4e24be018eb9 ("bonding: add new parameter ns_targets")
---
  drivers/net/bonding/bond_procfs.c | 13 +++++++++++++
  1 file changed, 13 insertions(+)
drivers/net/bonding/bond_procfs.c +0 -0
index cfe37be42be4..b6c012270e2e 100644

drivers/net/bonding/bond_procfs.c static void bond_info_show_master(struct seq_file *seq) · line 131

Quoted 3 lines
drivers/net/bonding/bond_procfs.c +0 -0
@@ -129,6 +129,19 @@ static void bond_info_show_master(struct seq_file *seq)
  			printed = 1;
  		}
  		seq_printf(seq, "\n");

Does this need to be guarded by "#if IS_ENABLED(CONFIG_IPV6)"?

Quoted 16 lines
drivers/net/bonding/bond_procfs.c +13 -0
+
+		printed = 0;
+		seq_printf(seq, "NS IPv6 target/s (xx::xx form):");
+
+		for (i = 0; (i < BOND_MAX_NS_TARGETS); i++) {
+			if (ipv6_addr_any(&bond->params.ns_targets[i]))
+				break;
+			if (printed)
+				seq_printf(seq, ",");
+			seq_printf(seq, " %pI6c", &bond->params.ns_targets[i]);
+			printed = 1;
+		}
+		seq_printf(seq, "\n");
  	}
 
  	if (BOND_MODE(bond) == BOND_MODE_8023AD) {
#2 lore raw
Quoted 16 lines · Jonathan Toppins
Quoted 2 lines · Hangbin Liu

When adding bond new parameter ns_targets. I forgot to print this in bond master proc info. After updating, the bond master info will looks

                                                              look ---^
Quoted 12 lines

like:
ARP IP target/s (n.n.n.n form): 192.168.1.254
NS IPv6 target/s (XX::XX form): 2022::1, 2022::2

Fixes 4e24be018eb9 ("bonding: add new parameter ns_targets")
---
  drivers/net/bonding/bond_procfs.c | 13 +++++++++++++
  1 file changed, 13 insertions(+)
drivers/net/bonding/bond_procfs.c +0 -0
index cfe37be42be4..b6c012270e2e 100644
Quoted 8 lines

drivers/net/bonding/bond_procfs.c static void bond_info_show_master(struct seq_file *seq) · line 131

Quoted 6 lines
drivers/net/bonding/bond_procfs.c +0 -0
@@ -129,6 +129,19 @@ static void bond_info_show_master(struct seq_file *seq)
  			printed = 1;
  		}
  		seq_printf(seq, "\n");

Does this need to be guarded by "#if IS_ENABLED(CONFIG_IPV6)"?

On looking at it, the definition of ns_targets in struct
bond_params isn't gated by CONFIG_IPV6, either (and is 256 bytes for just ns_targets).

I suspect this will all compile even if CONFIG_IPV6 isn't
enabled, since functions like ipv6_addr_any are defined regardless of the CONFIG_IPV6 setting, but it's dead code that shouldn't be built if CONFIG_IPV6 isn't set.

The options code for ns_targets depends on CONFIG_IPV6, so
making this conditional as well would be consistent.

	-J
Quoted 7 lines
Quoted 7 lines
drivers/net/bonding/bond_procfs.c +7 -0
+
+		printed = 0;
+		seq_printf(seq, "NS IPv6 target/s (xx::xx form):");
+
+		for (i = 0; (i < BOND_MAX_NS_TARGETS); i++) {
+			if (ipv6_addr_any(&bond->params.ns_targets[i]))
+				break;
Quoted 9 lines

drivers/net/bonding/bond_procfs.c static void bond_info_show_master(struct seq_file *seq) · line 147

Quoted 8 lines
drivers/net/bonding/bond_procfs.c +6 -0
+			if (printed)
+				seq_printf(seq, ",");
+			seq_printf(seq, " %pI6c", &bond->params.ns_targets[i]);
+			printed = 1;
+		}
+		seq_printf(seq, "\n");
  	}
    	if (BOND_MODE(bond) == BOND_MODE_8023AD) {

---
-Jay Vosburgh, [email protected]

#3 lore raw
Quoted 27 lines · Jay Vosburgh
Quoted 16 lines · Jonathan Toppins
Quoted 2 lines · Hangbin Liu

When adding bond new parameter ns_targets. I forgot to print this in bond master proc info. After updating, the bond master info will looks

                                                              look ---^
Quoted 12 lines

like:
ARP IP target/s (n.n.n.n form): 192.168.1.254
NS IPv6 target/s (XX::XX form): 2022::1, 2022::2

Fixes 4e24be018eb9 ("bonding: add new parameter ns_targets")
---
  drivers/net/bonding/bond_procfs.c | 13 +++++++++++++
  1 file changed, 13 insertions(+)
drivers/net/bonding/bond_procfs.c +0 -0
index cfe37be42be4..b6c012270e2e 100644
Quoted 8 lines

drivers/net/bonding/bond_procfs.c static void bond_info_show_master(struct seq_file *seq) · line 131

Quoted 6 lines
drivers/net/bonding/bond_procfs.c +0 -0
@@ -129,6 +129,19 @@ static void bond_info_show_master(struct seq_file *seq)
  			printed = 1;
  		}
  		seq_printf(seq, "\n");

Does this need to be guarded by "#if IS_ENABLED(CONFIG_IPV6)"?

Quoted 8 lines

On looking at it, the definition of ns_targets in struct
bond_params isn't gated by CONFIG_IPV6, either (and is 256 bytes for just ns_targets).

I suspect this will all compile even if CONFIG_IPV6 isn't
enabled, since functions like ipv6_addr_any are defined regardless of the CONFIG_IPV6 setting, but it's dead code that shouldn't be built if CONFIG_IPV6 isn't set.

Yes, I didn't protect the code if if could be build without CONFIG_IPV6. e.g. function bond_get_targets_ip6(). Do you think if I should also add the condition for bond_get_targets_ip6() and ns_targets in struct bond_params?

Quoted 3 lines

The options code for ns_targets depends on CONFIG_IPV6, so
making this conditional as well would be consistent.

I will add the protection for this patch.

Thanks
Hangbin

#4 lore raw
Quoted 37 lines · Hangbin Liu
Quoted 27 lines · Jay Vosburgh
Quoted 16 lines · Jonathan Toppins
Quoted 2 lines · Hangbin Liu

When adding bond new parameter ns_targets. I forgot to print this in bond master proc info. After updating, the bond master info will looks

                                                               look ---^
Quoted 12 lines

like:
ARP IP target/s (n.n.n.n form): 192.168.1.254
NS IPv6 target/s (XX::XX form): 2022::1, 2022::2

Fixes 4e24be018eb9 ("bonding: add new parameter ns_targets")
---
   drivers/net/bonding/bond_procfs.c | 13 +++++++++++++
   1 file changed, 13 insertions(+)
drivers/net/bonding/bond_procfs.c +0 -0
index cfe37be42be4..b6c012270e2e 100644
Quoted 8 lines

drivers/net/bonding/bond_procfs.c static void bond_info_show_master(struct seq_file *seq) · line 131

Quoted 6 lines
drivers/net/bonding/bond_procfs.c +0 -0
@@ -129,6 +129,19 @@ static void bond_info_show_master(struct seq_file *seq)
   			printed = 1;
   		}
   		seq_printf(seq, "\n");

Does this need to be guarded by "#if IS_ENABLED(CONFIG_IPV6)"?

Quoted 8 lines

On looking at it, the definition of ns_targets in struct
bond_params isn't gated by CONFIG_IPV6, either (and is 256 bytes for just ns_targets).

I suspect this will all compile even if CONFIG_IPV6 isn't
enabled, since functions like ipv6_addr_any are defined regardless of the CONFIG_IPV6 setting, but it's dead code that shouldn't be built if CONFIG_IPV6 isn't set.

Quoted 4 lines

Yes, I didn't protect the code if if could be build without CONFIG_IPV6. e.g. function bond_get_targets_ip6(). Do you think if I should also add the condition for bond_get_targets_ip6() and ns_targets in struct bond_params?

Yes, if the code that will use the entries in struct bonding and struct bond_params is going to be compiled out these entries should be compiled out as well.

Also, I was looking over the code in bond_options.c:bond_opts, and the entry BOND_OPT_NS_TARGETS is the only bonding option that will be left uninitialized if IPv6 is disabled. Does the bonding options infra handle this correctly or do you need a dummy set of values when IPv6 is disabled?

#5 lore raw
Quoted 8 lines · Jonathan Toppins
Quoted 4 lines

Yes, I didn't protect the code if if could be build without CONFIG_IPV6. e.g. function bond_get_targets_ip6(). Do you think if I should also add the condition for bond_get_targets_ip6() and ns_targets in struct bond_params?

Yes, if the code that will use the entries in struct bonding and struct bond_params is going to be compiled out these entries should be compiled out as well.

OK, I will fix it.

Quoted 6 lines

Also, I was looking over the code in bond_options.c:bond_opts, and the entry BOND_OPT_NS_TARGETS is the only bonding option that will be left uninitialized if IPv6 is disabled. Does the bonding options infra handle this correctly or do you need a dummy set of values when IPv6 is disabled?

The only entry to set ns_target is via netlink, which has protected by CONFIG_IPV6. So I think it's safe now. To make it more safer. I will add a dummy set.

Thanks
Hangbin