summaryrefslogtreecommitdiffstats
path: root/include/net/lwtunnel.h
diff options
context:
space:
mode:
authorTom Herbert <tom@herbertland.com>2015-08-17 16:42:24 -0400
committerDavid S. Miller <davem@davemloft.net>2015-08-18 00:33:05 -0400
commit2536862311d2276454ddef9dc36d6551a4b400fd (patch)
tree7be7caf4f95bdd2c50749dc2d42319acbc250030 /include/net/lwtunnel.h
parentf376d4adfdd2d860aea3e99aa86e98324621ece7 (diff)
lwt: Add support to redirect dst.input
This patch adds the capability to redirect dst input in the same way that dst output is redirected by LWT. Also, save the original dst.input and and dst.out when setting up lwtunnel redirection. These can be called by the client as a pass- through. Signed-off-by: Tom Herbert <tom@herbertland.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/net/lwtunnel.h')
-rw-r--r--include/net/lwtunnel.h30
1 files changed, 29 insertions, 1 deletions
diff --git a/include/net/lwtunnel.h b/include/net/lwtunnel.h
index 33bd30963a95..e25b60eb262d 100644
--- a/include/net/lwtunnel.h
+++ b/include/net/lwtunnel.h
@@ -11,12 +11,15 @@
11#define LWTUNNEL_HASH_SIZE (1 << LWTUNNEL_HASH_BITS) 11#define LWTUNNEL_HASH_SIZE (1 << LWTUNNEL_HASH_BITS)
12 12
13/* lw tunnel state flags */ 13/* lw tunnel state flags */
14#define LWTUNNEL_STATE_OUTPUT_REDIRECT 0x1 14#define LWTUNNEL_STATE_OUTPUT_REDIRECT BIT(0)
15#define LWTUNNEL_STATE_INPUT_REDIRECT BIT(1)
15 16
16struct lwtunnel_state { 17struct lwtunnel_state {
17 __u16 type; 18 __u16 type;
18 __u16 flags; 19 __u16 flags;
19 atomic_t refcnt; 20 atomic_t refcnt;
21 int (*orig_output)(struct sock *sk, struct sk_buff *skb);
22 int (*orig_input)(struct sk_buff *);
20 int len; 23 int len;
21 __u8 data[0]; 24 __u8 data[0];
22}; 25};
@@ -25,6 +28,7 @@ struct lwtunnel_encap_ops {
25 int (*build_state)(struct net_device *dev, struct nlattr *encap, 28 int (*build_state)(struct net_device *dev, struct nlattr *encap,
26 struct lwtunnel_state **ts); 29 struct lwtunnel_state **ts);
27 int (*output)(struct sock *sk, struct sk_buff *skb); 30 int (*output)(struct sock *sk, struct sk_buff *skb);
31 int (*input)(struct sk_buff *skb);
28 int (*fill_encap)(struct sk_buff *skb, 32 int (*fill_encap)(struct sk_buff *skb,
29 struct lwtunnel_state *lwtstate); 33 struct lwtunnel_state *lwtstate);
30 int (*get_encap_size)(struct lwtunnel_state *lwtstate); 34 int (*get_encap_size)(struct lwtunnel_state *lwtstate);
@@ -58,6 +62,13 @@ static inline bool lwtunnel_output_redirect(struct lwtunnel_state *lwtstate)
58 return false; 62 return false;
59} 63}
60 64
65static inline bool lwtunnel_input_redirect(struct lwtunnel_state *lwtstate)
66{
67 if (lwtstate && (lwtstate->flags & LWTUNNEL_STATE_INPUT_REDIRECT))
68 return true;
69
70 return false;
71}
61int lwtunnel_encap_add_ops(const struct lwtunnel_encap_ops *op, 72int lwtunnel_encap_add_ops(const struct lwtunnel_encap_ops *op,
62 unsigned int num); 73 unsigned int num);
63int lwtunnel_encap_del_ops(const struct lwtunnel_encap_ops *op, 74int lwtunnel_encap_del_ops(const struct lwtunnel_encap_ops *op,
@@ -72,6 +83,8 @@ struct lwtunnel_state *lwtunnel_state_alloc(int hdr_len);
72int lwtunnel_cmp_encap(struct lwtunnel_state *a, struct lwtunnel_state *b); 83int lwtunnel_cmp_encap(struct lwtunnel_state *a, struct lwtunnel_state *b);
73int lwtunnel_output(struct sock *sk, struct sk_buff *skb); 84int lwtunnel_output(struct sock *sk, struct sk_buff *skb);
74int lwtunnel_output6(struct sock *sk, struct sk_buff *skb); 85int lwtunnel_output6(struct sock *sk, struct sk_buff *skb);
86int lwtunnel_input(struct sk_buff *skb);
87int lwtunnel_input6(struct sk_buff *skb);
75 88
76#else 89#else
77 90
@@ -90,6 +103,11 @@ static inline bool lwtunnel_output_redirect(struct lwtunnel_state *lwtstate)
90 return false; 103 return false;
91} 104}
92 105
106static inline bool lwtunnel_input_redirect(struct lwtunnel_state *lwtstate)
107{
108 return false;
109}
110
93static inline int lwtunnel_encap_add_ops(const struct lwtunnel_encap_ops *op, 111static inline int lwtunnel_encap_add_ops(const struct lwtunnel_encap_ops *op,
94 unsigned int num) 112 unsigned int num)
95{ 113{
@@ -142,6 +160,16 @@ static inline int lwtunnel_output6(struct sock *sk, struct sk_buff *skb)
142 return -EOPNOTSUPP; 160 return -EOPNOTSUPP;
143} 161}
144 162
163static inline int lwtunnel_input(struct sk_buff *skb)
164{
165 return -EOPNOTSUPP;
166}
167
168static inline int lwtunnel_input6(struct sk_buff *skb)
169{
170 return -EOPNOTSUPP;
171}
172
145#endif 173#endif
146 174
147#endif /* __NET_LWTUNNEL_H */ 175#endif /* __NET_LWTUNNEL_H */