~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/include/net/lwtunnel.h

Version: ~ [ linux-5.4-rc3 ] ~ [ linux-5.3.6 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.79 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.149 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.196 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.196 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.140 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.75 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-3.9.11 ] ~ [ linux-3.8.13 ] ~ [ linux-3.7.10 ] ~ [ linux-3.6.11 ] ~ [ linux-3.5.7 ] ~ [ linux-3.4.113 ] ~ [ linux-3.3.8 ] ~ [ linux-3.2.102 ] ~ [ linux-3.1.10 ] ~ [ linux-3.0.101 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 #ifndef __NET_LWTUNNEL_H
  2 #define __NET_LWTUNNEL_H 1
  3 
  4 #include <linux/lwtunnel.h>
  5 #include <linux/netdevice.h>
  6 #include <linux/skbuff.h>
  7 #include <linux/types.h>
  8 #include <net/route.h>
  9 
 10 #define LWTUNNEL_HASH_BITS   7
 11 #define LWTUNNEL_HASH_SIZE   (1 << LWTUNNEL_HASH_BITS)
 12 
 13 /* lw tunnel state flags */
 14 #define LWTUNNEL_STATE_OUTPUT_REDIRECT  BIT(0)
 15 #define LWTUNNEL_STATE_INPUT_REDIRECT   BIT(1)
 16 
 17 struct lwtunnel_state {
 18         __u16           type;
 19         __u16           flags;
 20         atomic_t        refcnt;
 21         int             (*orig_output)(struct net *net, struct sock *sk, struct sk_buff *skb);
 22         int             (*orig_input)(struct sk_buff *);
 23         int             len;
 24         __u8            data[0];
 25 };
 26 
 27 struct lwtunnel_encap_ops {
 28         int (*build_state)(struct net_device *dev, struct nlattr *encap,
 29                            unsigned int family, const void *cfg,
 30                            struct lwtunnel_state **ts);
 31         int (*output)(struct net *net, struct sock *sk, struct sk_buff *skb);
 32         int (*input)(struct sk_buff *skb);
 33         int (*fill_encap)(struct sk_buff *skb,
 34                           struct lwtunnel_state *lwtstate);
 35         int (*get_encap_size)(struct lwtunnel_state *lwtstate);
 36         int (*cmp_encap)(struct lwtunnel_state *a, struct lwtunnel_state *b);
 37 };
 38 
 39 #ifdef CONFIG_LWTUNNEL
 40 static inline void lwtstate_free(struct lwtunnel_state *lws)
 41 {
 42         kfree(lws);
 43 }
 44 
 45 static inline struct lwtunnel_state *
 46 lwtstate_get(struct lwtunnel_state *lws)
 47 {
 48         if (lws)
 49                 atomic_inc(&lws->refcnt);
 50 
 51         return lws;
 52 }
 53 
 54 static inline void lwtstate_put(struct lwtunnel_state *lws)
 55 {
 56         if (!lws)
 57                 return;
 58 
 59         if (atomic_dec_and_test(&lws->refcnt))
 60                 lwtstate_free(lws);
 61 }
 62 
 63 static inline bool lwtunnel_output_redirect(struct lwtunnel_state *lwtstate)
 64 {
 65         if (lwtstate && (lwtstate->flags & LWTUNNEL_STATE_OUTPUT_REDIRECT))
 66                 return true;
 67 
 68         return false;
 69 }
 70 
 71 static inline bool lwtunnel_input_redirect(struct lwtunnel_state *lwtstate)
 72 {
 73         if (lwtstate && (lwtstate->flags & LWTUNNEL_STATE_INPUT_REDIRECT))
 74                 return true;
 75 
 76         return false;
 77 }
 78 int lwtunnel_encap_add_ops(const struct lwtunnel_encap_ops *op,
 79                            unsigned int num);
 80 int lwtunnel_encap_del_ops(const struct lwtunnel_encap_ops *op,
 81                            unsigned int num);
 82 int lwtunnel_build_state(struct net_device *dev, u16 encap_type,
 83                          struct nlattr *encap,
 84                          unsigned int family, const void *cfg,
 85                          struct lwtunnel_state **lws);
 86 int lwtunnel_fill_encap(struct sk_buff *skb,
 87                         struct lwtunnel_state *lwtstate);
 88 int lwtunnel_get_encap_size(struct lwtunnel_state *lwtstate);
 89 struct lwtunnel_state *lwtunnel_state_alloc(int hdr_len);
 90 int lwtunnel_cmp_encap(struct lwtunnel_state *a, struct lwtunnel_state *b);
 91 int lwtunnel_output(struct net *net, struct sock *sk, struct sk_buff *skb);
 92 int lwtunnel_input(struct sk_buff *skb);
 93 
 94 #else
 95 
 96 static inline void lwtstate_free(struct lwtunnel_state *lws)
 97 {
 98 }
 99 
100 static inline struct lwtunnel_state *
101 lwtstate_get(struct lwtunnel_state *lws)
102 {
103         return lws;
104 }
105 
106 static inline void lwtstate_put(struct lwtunnel_state *lws)
107 {
108 }
109 
110 static inline bool lwtunnel_output_redirect(struct lwtunnel_state *lwtstate)
111 {
112         return false;
113 }
114 
115 static inline bool lwtunnel_input_redirect(struct lwtunnel_state *lwtstate)
116 {
117         return false;
118 }
119 
120 static inline int lwtunnel_encap_add_ops(const struct lwtunnel_encap_ops *op,
121                                          unsigned int num)
122 {
123         return -EOPNOTSUPP;
124 
125 }
126 
127 static inline int lwtunnel_encap_del_ops(const struct lwtunnel_encap_ops *op,
128                                          unsigned int num)
129 {
130         return -EOPNOTSUPP;
131 }
132 
133 static inline int lwtunnel_build_state(struct net_device *dev, u16 encap_type,
134                                        struct nlattr *encap,
135                                        unsigned int family, const void *cfg,
136                                        struct lwtunnel_state **lws)
137 {
138         return -EOPNOTSUPP;
139 }
140 
141 static inline int lwtunnel_fill_encap(struct sk_buff *skb,
142                                       struct lwtunnel_state *lwtstate)
143 {
144         return 0;
145 }
146 
147 static inline int lwtunnel_get_encap_size(struct lwtunnel_state *lwtstate)
148 {
149         return 0;
150 }
151 
152 static inline struct lwtunnel_state *lwtunnel_state_alloc(int hdr_len)
153 {
154         return NULL;
155 }
156 
157 static inline int lwtunnel_cmp_encap(struct lwtunnel_state *a,
158                                      struct lwtunnel_state *b)
159 {
160         return 0;
161 }
162 
163 static inline int lwtunnel_output(struct net *net, struct sock *sk, struct sk_buff *skb)
164 {
165         return -EOPNOTSUPP;
166 }
167 
168 static inline int lwtunnel_input(struct sk_buff *skb)
169 {
170         return -EOPNOTSUPP;
171 }
172 
173 #endif /* CONFIG_LWTUNNEL */
174 
175 #define MODULE_ALIAS_RTNL_LWT(encap_type) MODULE_ALIAS("rtnl-lwt-" __stringify(encap_type))
176 
177 #endif /* __NET_LWTUNNEL_H */
178 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp