hc
2024-05-10 ee930fffee469d076998274a2ca55e13dc1efb67
kernel/include/net/lwtunnel.h
....@@ -16,9 +16,12 @@
1616 #define LWTUNNEL_STATE_INPUT_REDIRECT BIT(1)
1717 #define LWTUNNEL_STATE_XMIT_REDIRECT BIT(2)
1818
19
+/* LWTUNNEL_XMIT_CONTINUE should be distinguishable from dst_output return
20
+ * values (NET_XMIT_xxx and NETDEV_TX_xxx in linux/netdevice.h) for safety.
21
+ */
1922 enum {
2023 LWTUNNEL_XMIT_DONE,
21
- LWTUNNEL_XMIT_CONTINUE,
24
+ LWTUNNEL_XMIT_CONTINUE = 0x100,
2225 };
2326
2427
....@@ -30,11 +33,11 @@
3033 int (*orig_output)(struct net *net, struct sock *sk, struct sk_buff *skb);
3134 int (*orig_input)(struct sk_buff *);
3235 struct rcu_head rcu;
33
- __u8 data[0];
36
+ __u8 data[];
3437 };
3538
3639 struct lwtunnel_encap_ops {
37
- int (*build_state)(struct nlattr *encap,
40
+ int (*build_state)(struct net *net, struct nlattr *encap,
3841 unsigned int family, const void *cfg,
3942 struct lwtunnel_state **ts,
4043 struct netlink_ext_ack *extack);
....@@ -113,19 +116,21 @@
113116 struct netlink_ext_ack *extack);
114117 int lwtunnel_valid_encap_type_attr(struct nlattr *attr, int len,
115118 struct netlink_ext_ack *extack);
116
-int lwtunnel_build_state(u16 encap_type,
119
+int lwtunnel_build_state(struct net *net, u16 encap_type,
117120 struct nlattr *encap,
118121 unsigned int family, const void *cfg,
119122 struct lwtunnel_state **lws,
120123 struct netlink_ext_ack *extack);
121
-int lwtunnel_fill_encap(struct sk_buff *skb,
122
- struct lwtunnel_state *lwtstate);
124
+int lwtunnel_fill_encap(struct sk_buff *skb, struct lwtunnel_state *lwtstate,
125
+ int encap_attr, int encap_type_attr);
123126 int lwtunnel_get_encap_size(struct lwtunnel_state *lwtstate);
124127 struct lwtunnel_state *lwtunnel_state_alloc(int hdr_len);
125128 int lwtunnel_cmp_encap(struct lwtunnel_state *a, struct lwtunnel_state *b);
126129 int lwtunnel_output(struct net *net, struct sock *sk, struct sk_buff *skb);
127130 int lwtunnel_input(struct sk_buff *skb);
128131 int lwtunnel_xmit(struct sk_buff *skb);
132
+int bpf_lwt_push_ip_encap(struct sk_buff *skb, void *hdr, u32 len,
133
+ bool ingress);
129134
130135 static inline void lwtunnel_set_redirect(struct dst_entry *dst)
131136 {
....@@ -207,7 +212,7 @@
207212 return 0;
208213 }
209214
210
-static inline int lwtunnel_build_state(u16 encap_type,
215
+static inline int lwtunnel_build_state(struct net *net, u16 encap_type,
211216 struct nlattr *encap,
212217 unsigned int family, const void *cfg,
213218 struct lwtunnel_state **lws,
....@@ -217,7 +222,8 @@
217222 }
218223
219224 static inline int lwtunnel_fill_encap(struct sk_buff *skb,
220
- struct lwtunnel_state *lwtstate)
225
+ struct lwtunnel_state *lwtstate,
226
+ int encap_attr, int encap_type_attr)
221227 {
222228 return 0;
223229 }