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
This commit is contained in:
Andrey V. Elsukov 2018-06-28 11:39:27 +00:00
parent 0df37a208c
commit 6e081509db
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=335760
5 changed files with 15 additions and 0 deletions

View File

@ -312,6 +312,9 @@ me_lookup(const struct mbuf *m, int off, int proto, void **arg)
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,

View File

@ -289,6 +289,9 @@ in_gif_lookup(const struct mbuf *m, int off, int proto, void **arg)
struct gif_softc *sc;
int ret;
if (V_ipv4_hashtbl == NULL)
return (0);
MPASS(in_epoch());
ip = mtod(m, const struct ip *);
/*

View File

@ -115,6 +115,9 @@ in_gre_lookup(const struct mbuf *m, int off, int proto, void **arg)
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,

View File

@ -309,6 +309,9 @@ in6_gif_lookup(const struct mbuf *m, int off, int proto, void **arg)
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

View File

@ -107,6 +107,9 @@ in6_gre_lookup(const struct mbuf *m, int off, int proto, void **arg)
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) {