Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src Split ip_ecn code into its own module, so it can be shared b...



details:   https://anonhg.NetBSD.org/src/rev/3ac443ee1271
branches:  trunk
changeset: 828348:3ac443ee1271
user:      pgoyette <pgoyette%NetBSD.org@localhost>
date:      Sat Dec 09 08:03:06 2017 +0000

description:
Split ip_ecn code into its own module, so it can be shared between
gif(4), stf(4), and ipsec(4).  Without this, loading the if_gif
module can result in redefined global symbols if either ipsec(4) or
stf(4) but not gif(4) is built into the kernel.

Fixes PR kern/52795 (as reported by martin@ via irc).

XXX pullup to netbsd-8

diffstat:

 distrib/sets/lists/modules/mi |   4 +++-
 sys/modules/Makefile          |   3 ++-
 sys/modules/if_gif/Makefile   |   4 ++--
 sys/modules/ip_ecn/Makefile   |  13 +++++++++++++
 sys/net/if_gif.c              |   6 +++---
 sys/netinet/ip_ecn.c          |  22 ++++++++++++++++++++--
 6 files changed, 43 insertions(+), 9 deletions(-)

diffs (141 lines):

diff -r 5a905d12026d -r 3ac443ee1271 distrib/sets/lists/modules/mi
--- a/distrib/sets/lists/modules/mi     Sat Dec 09 05:18:45 2017 +0000
+++ b/distrib/sets/lists/modules/mi     Sat Dec 09 08:03:06 2017 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.111 2017/06/11 22:22:36 pgoyette Exp $
+# $NetBSD: mi,v 1.112 2017/12/09 08:03:06 pgoyette Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -182,6 +182,8 @@
 ./@MODULEDIR@/if_vlan/if_vlan.kmod             base-kernel-modules     kmod
 ./@MODULEDIR@/iic                              base-kernel-modules     kmod
 ./@MODULEDIR@/iic/iic.kmod                     base-kernel-modules     kmod
+./@MODULEDIR@/ip_ecn                           base-kernel-modules     kmod
+./@MODULEDIR@/ip_ecn/ip_ecn.kmod               base-kernel-modules     kmod
 ./@MODULEDIR@/ipl                              base-kernel-modules     kmod
 ./@MODULEDIR@/ipl/ipl.kmod                     base-kernel-modules     kmod
 ./@MODULEDIR@/iscsi                            base-kernel-modules     kmod,iscsi
diff -r 5a905d12026d -r 3ac443ee1271 sys/modules/Makefile
--- a/sys/modules/Makefile      Sat Dec 09 05:18:45 2017 +0000
+++ b/sys/modules/Makefile      Sat Dec 09 08:03:06 2017 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.195 2017/08/11 12:58:14 maxv Exp $
+#      $NetBSD: Makefile,v 1.196 2017/12/09 08:03:07 pgoyette Exp $
 
 .include <bsd.own.mk>
 
@@ -70,6 +70,7 @@
 SUBDIR+=       if_tun tun
 SUBDIR+=       if_vlan
 SUBDIR+=       iic
+SUBDIR+=       ip_ecn
 SUBDIR+=       ipl
 SUBDIR+=       kernfs
 SUBDIR+=       layerfs
diff -r 5a905d12026d -r 3ac443ee1271 sys/modules/if_gif/Makefile
--- a/sys/modules/if_gif/Makefile       Sat Dec 09 05:18:45 2017 +0000
+++ b/sys/modules/if_gif/Makefile       Sat Dec 09 08:03:06 2017 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.2 2016/08/18 11:41:58 knakahara Exp $
+# $NetBSD: Makefile,v 1.3 2017/12/09 08:03:07 pgoyette Exp $
 
 .include "../Makefile.inc"
 
@@ -6,7 +6,7 @@
 
 KMOD=          if_gif
 IOCONF=                gif.ioconf
-SRCS=          if_gif.c in_gif.c in6_gif.c ip_ecn.c
+SRCS=          if_gif.c in_gif.c in6_gif.c
 
 CPPFLAGS+=     -DINET
 CPPFLAGS+=     -DINET6
diff -r 5a905d12026d -r 3ac443ee1271 sys/modules/ip_ecn/Makefile
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/modules/ip_ecn/Makefile       Sat Dec 09 08:03:06 2017 +0000
@@ -0,0 +1,13 @@
+#      $NetBSD: Makefile,v 1.1 2017/12/09 08:03:07 pgoyette Exp $
+
+.include "../Makefile.inc"
+
+.PATH: ${S}/netinet
+
+KMOD=  ip_ecn
+SRCS=  ip_ecn.c
+
+CPPFLAGS+=     -DINET
+CPPFLAGS+=     -DINET6
+
+.include <bsd.kmodule.mk>
diff -r 5a905d12026d -r 3ac443ee1271 sys/net/if_gif.c
--- a/sys/net/if_gif.c  Sat Dec 09 05:18:45 2017 +0000
+++ b/sys/net/if_gif.c  Sat Dec 09 08:03:06 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_gif.c,v 1.135 2017/12/06 08:23:17 knakahara Exp $   */
+/*     $NetBSD: if_gif.c,v 1.136 2017/12/09 08:03:06 pgoyette Exp $    */
 /*     $KAME: if_gif.c,v 1.76 2001/08/20 02:01:02 kjc Exp $    */
 
 /*
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_gif.c,v 1.135 2017/12/06 08:23:17 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_gif.c,v 1.136 2017/12/09 08:03:06 pgoyette Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -1187,4 +1187,4 @@
  */
 #include "if_module.h"
 
-IF_MODULE(MODULE_CLASS_DRIVER, gif, "")
+IF_MODULE(MODULE_CLASS_DRIVER, gif, "ip_ecn")
diff -r 5a905d12026d -r 3ac443ee1271 sys/netinet/ip_ecn.c
--- a/sys/netinet/ip_ecn.c      Sat Dec 09 05:18:45 2017 +0000
+++ b/sys/netinet/ip_ecn.c      Sat Dec 09 08:03:06 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ip_ecn.c,v 1.16 2015/08/24 22:21:26 pooka Exp $        */
+/*     $NetBSD: ip_ecn.c,v 1.17 2017/12/09 08:03:07 pgoyette Exp $     */
 /*     $KAME: ip_ecn.c,v 1.11 2001/05/03 16:09:29 itojun Exp $ */
 
 /*
@@ -36,7 +36,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ip_ecn.c,v 1.16 2015/08/24 22:21:26 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip_ecn.c,v 1.17 2017/12/09 08:03:07 pgoyette Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -47,6 +47,7 @@
 #include <sys/malloc.h>
 #include <sys/mbuf.h>
 #include <sys/errno.h>
+#include <sys/module.h>
 
 #include <netinet/in.h>
 #include <netinet/in_systm.h>
@@ -130,3 +131,20 @@
        *inner |= htonl((u_int32_t)inner8 << 20);
 }
 #endif
+
+MODULE(MODULE_CLASS_MISC, ip_ecn, NULL);
+
+static int
+ip_ecn_modcmd(modcmd_t cmd, void *arg)
+{
+ 
+       switch (cmd) {
+       case MODULE_CMD_INIT:
+       case MODULE_CMD_FINI:
+               return 0;
+ 
+       default:
+               return ENOTTY;
+        }
+}
+



Home | Main Index | Thread Index | Old Index