Skip to content

Commit

Permalink
ipv6: Move common init code for rt6_info to a new function rt6_info_i…
Browse files Browse the repository at this point in the history
…nit()

Introduce rt6_info_init() to do the common init work for
'struct rt6_info' (after calling dst_alloc).

It is a prep work to fix the rt6_info init logic in the
ip6_blackhole_route().

Signed-off-by: Martin KaFai Lau <kafai@fb.com>
Cc: Hannes Frederic Sowa <hannes@stressinduktion.org>
Cc: Julian Anastasov <ja@ssi.bg>
Cc: Phil Sutter <phil@nwl.cc>
Cc: Steffen Klassert <steffen.klassert@secunet.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Martin KaFai Lau authored and David S. Miller committed Oct 16, 2015
1 parent 53ca376 commit ebfa45f
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions net/ipv6/route.c
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,15 @@ static const struct rt6_info ip6_blk_hole_entry_template = {

#endif

static void rt6_info_init(struct rt6_info *rt)
{
struct dst_entry *dst = &rt->dst;

memset(dst + 1, 0, sizeof(*rt) - sizeof(*dst));
INIT_LIST_HEAD(&rt->rt6i_siblings);
INIT_LIST_HEAD(&rt->rt6i_uncached);
}

/* allocate dst with ip6_dst_ops */
static struct rt6_info *__ip6_dst_alloc(struct net *net,
struct net_device *dev,
Expand All @@ -327,13 +336,9 @@ static struct rt6_info *__ip6_dst_alloc(struct net *net,
struct rt6_info *rt = dst_alloc(&net->ipv6.ip6_dst_ops, dev,
0, DST_OBSOLETE_FORCE_CHK, flags);

if (rt) {
struct dst_entry *dst = &rt->dst;
if (rt)
rt6_info_init(rt);

memset(dst + 1, 0, sizeof(*rt) - sizeof(*dst));
INIT_LIST_HEAD(&rt->rt6i_siblings);
INIT_LIST_HEAD(&rt->rt6i_uncached);
}
return rt;
}

Expand Down

0 comments on commit ebfa45f

Please sign in to comment.