Skip to contentSkip to conversation

net: secure_seq: Move net_secret_init() definition into CONFIG_IPV6 if block

PATCH New Fabio Estevam 2 participants 3 messages Oct 5, 2013 – Oct 7, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: secure_seq: Move net_secret_init() definition into CONFIG_IPV6 if block

From: Fabio Estevam <[email protected]>

Commit 9a3bab6b05 (net: net_secret should not depend on TCP) introduced the following build warning when CONFIG_IPV6 is not selected:

net/core/secure_seq.c:17:13: warning: 'net_secret_init' defined but not used [-Wunused-function]

Fix it by moving net_secret_init(void) inside the '#if IS_ENABLED(CONFIG_IPV6)' block.

---
 net/core/secure_seq.c | 36 ++++++++++++++++++------------------
 1 file changed, 18 insertions(+), 18 deletions(-)
net/core/secure_seq.c +18 -18
index 3f1ec15..ee70541 100644
@@ -10,6 +10,24 @@
 
 #include <net/secure_seq.h>
 
+#ifdef CONFIG_INET
+static u32 seq_scale(u32 seq)
+{
+	/*
+	 *	As close as possible to RFC 793, which
+	 *	suggests using a 250 kHz clock.
+	 *	Further reading shows this assumes 2 Mb/s networks.
+	 *	For 10 Mb/s Ethernet, a 1 MHz clock is appropriate.
+	 *	For 10 Gb/s Ethernet, a 1 GHz clock should be ok, but
+	 *	we also need to limit the resolution so that the u32 seq
+	 *	overlaps less than one time per MSL (2 minutes).
+	 *	Choosing a clock of 64 ns period is OK. (period of 274 s)
+	 */
+	return seq + (ktime_to_ns(ktime_get_real()) >> 6);
+}
+#endif
+
+#if IS_ENABLED(CONFIG_IPV6)
 #define NET_SECRET_SIZE (MD5_MESSAGE_BYTES / 4)
 
 static u32 net_secret[NET_SECRET_SIZE] ____cacheline_aligned;
@@ -30,24 +48,6 @@ static void net_secret_init(void)
 	}
 }
 
-#ifdef CONFIG_INET
-static u32 seq_scale(u32 seq)
-{
-	/*
-	 *	As close as possible to RFC 793, which
-	 *	suggests using a 250 kHz clock.
-	 *	Further reading shows this assumes 2 Mb/s networks.
-	 *	For 10 Mb/s Ethernet, a 1 MHz clock is appropriate.
-	 *	For 10 Gb/s Ethernet, a 1 GHz clock should be ok, but
-	 *	we also need to limit the resolution so that the u32 seq
-	 *	overlaps less than one time per MSL (2 minutes).
-	 *	Choosing a clock of 64 ns period is OK. (period of 274 s)
-	 */
-	return seq + (ktime_to_ns(ktime_get_real()) >> 6);
-}
-#endif
-
-#if IS_ENABLED(CONFIG_IPV6)
 __u32 secure_tcpv6_sequence_number(const __be32 *saddr, const __be32 *daddr,
 				   __be16 sport, __be16 dport)
 {
Signature · 1 line
1.8.1.2
#1 lore raw

PATCH v2 1/1 net: secure_seq: Fix warning when CONFIG_IPV6 and CONFIG_INET are not selected

From: Fabio Estevam <[email protected]>

net_secret() is only used when CONFIG_IPV6 or CONFIG_INET are selected.

Building a defconfig with both of these symbols unselected (Using the ARM at91sam9rl_defconfig, for example) leads to the following build warning:

$ make at91sam9rl_defconfig
#
# configuration written to .config
#
$ make net/core/secure_seq.o
scripts/kconfig/conf --silentoldconfig Kconfig
  CHK     include/config/kernel.release
  CHK     include/generated/uapi/linux/version.h
  CHK     include/generated/utsrelease.h
make[1]: `include/generated/mach-types.h' is up to date.
  CALL    scripts/checksyscalls.sh
  CC      net/core/secure_seq.o
net/core/secure_seq.c:17:13: warning: 'net_secret_init' defined but not used [-Wunused-function]

Fix this warning by protecting the definition of net_secret() with these symbols.

---
Changes since v1:
- Add #if IS_ENABLED(CONFIG_IPV6) || IS_ENABLED(CONFIG_INET)

 net/core/secure_seq.c | 2 ++
 1 file changed, 2 insertions(+)
net/core/secure_seq.c +2 -0
index 3f1ec15..8d9d05e 100644
@@ -10,6 +10,7 @@
 
 #include <net/secure_seq.h>
 
+#if IS_ENABLED(CONFIG_IPV6) || IS_ENABLED(CONFIG_INET)
 #define NET_SECRET_SIZE (MD5_MESSAGE_BYTES / 4)
 
 static u32 net_secret[NET_SECRET_SIZE] ____cacheline_aligned;
@@ -29,6 +30,7 @@ static void net_secret_init(void)
 		cmpxchg(&net_secret[--i], 0, tmp);
 	}
 }
+#endif
 
 #ifdef CONFIG_INET
 static u32 seq_scale(u32 seq)
Signature · 1 line
1.8.1.2
maintainer
#2 lore raw

Re: [PATCH v2] net: secure_seq: Fix warning when CONFIG_IPV6 and CONFIG_INET are not selected

From: Fabio Estevam <[email protected]>
Date: Sat, 5 Oct 2013 17:56:59 -0300

Quoted 6 lines

From: Fabio Estevam <[email protected]>

net_secret() is only used when CONFIG_IPV6 or CONFIG_INET are selected.

Building a defconfig with both of these symbols unselected (Using the ARM at91sam9rl_defconfig, for example) leads to the following build warning:

...

Quoted 8 lines

Fix this warning by protecting the definition of net_secret() with these symbols.

---
Changes since v1:
- Add #if IS_ENABLED(CONFIG_IPV6) || IS_ENABLED(CONFIG_INET)

This looks a lot better, applied, thanks.