Skip to content

Commit

Permalink
ipv6: sr: select DST_CACHE by default
Browse files Browse the repository at this point in the history
When CONFIG_IPV6_SEG6_LWTUNNEL is selected, automatically select DST_CACHE.
This allows to remove multiple ifdefs.

Signed-off-by: David Lebrun <david.lebrun@uclouvain.be>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
David Lebrun authored and davem330 committed Mar 27, 2017
1 parent 656455b commit 402a5bc
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 18 deletions.
1 change: 1 addition & 0 deletions net/ipv6/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@ config IPV6_SEG6_LWTUNNEL
bool "IPv6: Segment Routing Header encapsulation support"
depends on IPV6
select LWTUNNEL
select DST_CACHE
---help---
Support for encapsulation of packets within an outer IPv6
header and a Segment Routing Header using the lightweight
Expand Down
18 changes: 0 additions & 18 deletions net/ipv6/seg6_iptunnel.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,13 @@
#include <linux/seg6_iptunnel.h>
#include <net/addrconf.h>
#include <net/ip6_route.h>
#ifdef CONFIG_DST_CACHE
#include <net/dst_cache.h>
#endif
#ifdef CONFIG_IPV6_SEG6_HMAC
#include <net/seg6_hmac.h>
#endif

struct seg6_lwt {
#ifdef CONFIG_DST_CACHE
struct dst_cache cache;
#endif
struct seg6_iptunnel_encap tuninfo[0];
};

Expand Down Expand Up @@ -250,25 +246,21 @@ static int seg6_input(struct sk_buff *skb)

slwt = seg6_lwt_lwtunnel(orig_dst->lwtstate);

#ifdef CONFIG_DST_CACHE
preempt_disable();
dst = dst_cache_get(&slwt->cache);
preempt_enable();
#endif

skb_dst_drop(skb);

if (!dst) {
ip6_route_input(skb);
#ifdef CONFIG_DST_CACHE
dst = skb_dst(skb);
if (!dst->error) {
preempt_disable();
dst_cache_set_ip6(&slwt->cache, dst,
&ipv6_hdr(skb)->saddr);
preempt_enable();
}
#endif
} else {
skb_dst_set(skb, dst);
}
Expand All @@ -289,11 +281,9 @@ static int seg6_output(struct net *net, struct sock *sk, struct sk_buff *skb)

slwt = seg6_lwt_lwtunnel(orig_dst->lwtstate);

#ifdef CONFIG_DST_CACHE
preempt_disable();
dst = dst_cache_get(&slwt->cache);
preempt_enable();
#endif

if (unlikely(!dst)) {
struct ipv6hdr *hdr = ipv6_hdr(skb);
Expand All @@ -312,11 +302,9 @@ static int seg6_output(struct net *net, struct sock *sk, struct sk_buff *skb)
goto drop;
}

#ifdef CONFIG_DST_CACHE
preempt_disable();
dst_cache_set_ip6(&slwt->cache, dst, &fl6.saddr);
preempt_enable();
#endif
}

skb_dst_drop(skb);
Expand Down Expand Up @@ -380,13 +368,11 @@ static int seg6_build_state(struct nlattr *nla,

slwt = seg6_lwt_lwtunnel(newts);

#ifdef CONFIG_DST_CACHE
err = dst_cache_init(&slwt->cache, GFP_KERNEL);
if (err) {
kfree(newts);
return err;
}
#endif

memcpy(&slwt->tuninfo, tuninfo, tuninfo_len);

Expand All @@ -400,12 +386,10 @@ static int seg6_build_state(struct nlattr *nla,
return 0;
}

#ifdef CONFIG_DST_CACHE
static void seg6_destroy_state(struct lwtunnel_state *lwt)
{
dst_cache_destroy(&seg6_lwt_lwtunnel(lwt)->cache);
}
#endif

static int seg6_fill_encap_info(struct sk_buff *skb,
struct lwtunnel_state *lwtstate)
Expand Down Expand Up @@ -439,9 +423,7 @@ static int seg6_encap_cmp(struct lwtunnel_state *a, struct lwtunnel_state *b)

static const struct lwtunnel_encap_ops seg6_iptun_ops = {
.build_state = seg6_build_state,
#ifdef CONFIG_DST_CACHE
.destroy_state = seg6_destroy_state,
#endif
.output = seg6_output,
.input = seg6_input,
.fill_encap = seg6_fill_encap_info,
Expand Down

0 comments on commit 402a5bc

Please sign in to comment.