svn commit: r335760 - in head/sys: net netinet netinet6

Andrey V. Elsukov ae at FreeBSD.org
Thu Jun 28 11:39:29 UTC 2018


Author: ae
Date: Thu Jun 28 11:39:27 2018
New Revision: 335760
URL: https://svnweb.freebsd.org/changeset/base/335760

Log:
  Add NULL pointer check.
  
  encap_lookup_t method can be invoked by IP encap subsytem even if none
  of gif/gre/me interfaces are exist. Hash tables are allocated on demand,
  when first interface is created. So, make NULL pointer check before
  doing access to hash table.
  
  PR:		229378

Modified:
  head/sys/net/if_me.c
  head/sys/netinet/in_gif.c
  head/sys/netinet/ip_gre.c
  head/sys/netinet6/in6_gif.c
  head/sys/netinet6/ip6_gre.c

Modified: head/sys/net/if_me.c
==============================================================================
--- head/sys/net/if_me.c	Thu Jun 28 09:42:30 2018	(r335759)
+++ head/sys/net/if_me.c	Thu Jun 28 11:39:27 2018	(r335760)
@@ -312,6 +312,9 @@ me_lookup(const struct mbuf *m, int off, int proto, vo
 	const struct ip *ip;
 	struct me_softc *sc;
 
+	if (V_me_hashtbl == NULL)
+		return (0);
+
 	MPASS(in_epoch());
 	ip = mtod(m, const struct ip *);
 	CK_LIST_FOREACH(sc, &ME_HASH(ip->ip_dst.s_addr,

Modified: head/sys/netinet/in_gif.c
==============================================================================
--- head/sys/netinet/in_gif.c	Thu Jun 28 09:42:30 2018	(r335759)
+++ head/sys/netinet/in_gif.c	Thu Jun 28 11:39:27 2018	(r335760)
@@ -289,6 +289,9 @@ in_gif_lookup(const struct mbuf *m, int off, int proto
 	struct gif_softc *sc;
 	int ret;
 
+	if (V_ipv4_hashtbl == NULL)
+		return (0);
+
 	MPASS(in_epoch());
 	ip = mtod(m, const struct ip *);
 	/*

Modified: head/sys/netinet/ip_gre.c
==============================================================================
--- head/sys/netinet/ip_gre.c	Thu Jun 28 09:42:30 2018	(r335759)
+++ head/sys/netinet/ip_gre.c	Thu Jun 28 11:39:27 2018	(r335760)
@@ -115,6 +115,9 @@ in_gre_lookup(const struct mbuf *m, int off, int proto
 	const struct ip *ip;
 	struct gre_softc *sc;
 
+	if (V_ipv4_hashtbl == NULL)
+		return (0);
+
 	MPASS(in_epoch());
 	ip = mtod(m, const struct ip *);
 	CK_LIST_FOREACH(sc, &GRE_HASH(ip->ip_dst.s_addr,

Modified: head/sys/netinet6/in6_gif.c
==============================================================================
--- head/sys/netinet6/in6_gif.c	Thu Jun 28 09:42:30 2018	(r335759)
+++ head/sys/netinet6/in6_gif.c	Thu Jun 28 11:39:27 2018	(r335760)
@@ -309,6 +309,9 @@ in6_gif_lookup(const struct mbuf *m, int off, int prot
 	struct gif_softc *sc;
 	int ret;
 
+	if (V_ipv6_hashtbl == NULL)
+		return (0);
+
 	MPASS(in_epoch());
 	/*
 	 * NOTE: it is safe to iterate without any locking here, because softc

Modified: head/sys/netinet6/ip6_gre.c
==============================================================================
--- head/sys/netinet6/ip6_gre.c	Thu Jun 28 09:42:30 2018	(r335759)
+++ head/sys/netinet6/ip6_gre.c	Thu Jun 28 11:39:27 2018	(r335760)
@@ -107,6 +107,9 @@ in6_gre_lookup(const struct mbuf *m, int off, int prot
 	const struct ip6_hdr *ip6;
 	struct gre_softc *sc;
 
+	if (V_ipv6_hashtbl == NULL)
+		return (0);
+
 	MPASS(in_epoch());
 	ip6 = mtod(m, const struct ip6_hdr *);
 	CK_LIST_FOREACH(sc, &GRE_HASH(&ip6->ip6_dst, &ip6->ip6_src), chain) {


More information about the svn-src-all mailing list