diff options
author | Jiri Benc <jbenc@redhat.com> | 2015-08-14 10:40:40 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-08-17 17:07:15 -0400 |
commit | a1c234f95cae2d293047bb6c36e7a4840dbac815 (patch) | |
tree | 5dfecd1a62471db38504511b8c9d79c150e8330f | |
parent | 62ee783bf1f872ba879e088a669b04afebee899b (diff) |
lwtunnel: rename ip lwtunnel attributes
We already have IFLA_IPTUN_ netlink attributes. The IP_TUN_ attributes look
very similar, yet they serve very different purpose. This is confusing for
anyone trying to implement a user space tool supporting lwt.
As the IP_TUN_ attributes are used only for the lightweight tunnels, prefix
them with LWTUNNEL_IP_ instead to make their purpose clear. Also, it's more
logical to have them in lwtunnel.h together with the encap enum.
Fixes: 3093fbe7ff4b ("route: Per route IP tunnel metadata via lightweight tunnel")
Signed-off-by: Jiri Benc <jbenc@redhat.com>
Acked-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | include/uapi/linux/lwtunnel.h | 14 | ||||
-rw-r--r-- | include/uapi/linux/rtnetlink.h | 15 | ||||
-rw-r--r-- | net/ipv4/ip_tunnel_core.c | 86 |
3 files changed, 57 insertions, 58 deletions
diff --git a/include/uapi/linux/lwtunnel.h b/include/uapi/linux/lwtunnel.h index 31377bbea3f8..3bf223bc2367 100644 --- a/include/uapi/linux/lwtunnel.h +++ b/include/uapi/linux/lwtunnel.h | |||
@@ -12,5 +12,19 @@ enum lwtunnel_encap_types { | |||
12 | 12 | ||
13 | #define LWTUNNEL_ENCAP_MAX (__LWTUNNEL_ENCAP_MAX - 1) | 13 | #define LWTUNNEL_ENCAP_MAX (__LWTUNNEL_ENCAP_MAX - 1) |
14 | 14 | ||
15 | enum lwtunnel_ip_t { | ||
16 | LWTUNNEL_IP_UNSPEC, | ||
17 | LWTUNNEL_IP_ID, | ||
18 | LWTUNNEL_IP_DST, | ||
19 | LWTUNNEL_IP_SRC, | ||
20 | LWTUNNEL_IP_TTL, | ||
21 | LWTUNNEL_IP_TOS, | ||
22 | LWTUNNEL_IP_SPORT, | ||
23 | LWTUNNEL_IP_DPORT, | ||
24 | LWTUNNEL_IP_FLAGS, | ||
25 | __LWTUNNEL_IP_MAX, | ||
26 | }; | ||
27 | |||
28 | #define LWTUNNEL_IP_MAX (__LWTUNNEL_IP_MAX - 1) | ||
15 | 29 | ||
16 | #endif /* _UAPI_LWTUNNEL_H_ */ | 30 | #endif /* _UAPI_LWTUNNEL_H_ */ |
diff --git a/include/uapi/linux/rtnetlink.h b/include/uapi/linux/rtnetlink.h index 47d24cb3fbc1..0d3d3cc43356 100644 --- a/include/uapi/linux/rtnetlink.h +++ b/include/uapi/linux/rtnetlink.h | |||
@@ -286,21 +286,6 @@ enum rt_class_t { | |||
286 | 286 | ||
287 | /* Routing message attributes */ | 287 | /* Routing message attributes */ |
288 | 288 | ||
289 | enum ip_tunnel_t { | ||
290 | IP_TUN_UNSPEC, | ||
291 | IP_TUN_ID, | ||
292 | IP_TUN_DST, | ||
293 | IP_TUN_SRC, | ||
294 | IP_TUN_TTL, | ||
295 | IP_TUN_TOS, | ||
296 | IP_TUN_SPORT, | ||
297 | IP_TUN_DPORT, | ||
298 | IP_TUN_FLAGS, | ||
299 | __IP_TUN_MAX, | ||
300 | }; | ||
301 | |||
302 | #define IP_TUN_MAX (__IP_TUN_MAX - 1) | ||
303 | |||
304 | enum rtattr_type_t { | 289 | enum rtattr_type_t { |
305 | RTA_UNSPEC, | 290 | RTA_UNSPEC, |
306 | RTA_DST, | 291 | RTA_DST, |
diff --git a/net/ipv4/ip_tunnel_core.c b/net/ipv4/ip_tunnel_core.c index 5512f4e4ec1b..fd6319681c50 100644 --- a/net/ipv4/ip_tunnel_core.c +++ b/net/ipv4/ip_tunnel_core.c | |||
@@ -192,15 +192,15 @@ struct rtnl_link_stats64 *ip_tunnel_get_stats64(struct net_device *dev, | |||
192 | } | 192 | } |
193 | EXPORT_SYMBOL_GPL(ip_tunnel_get_stats64); | 193 | EXPORT_SYMBOL_GPL(ip_tunnel_get_stats64); |
194 | 194 | ||
195 | static const struct nla_policy ip_tun_policy[IP_TUN_MAX + 1] = { | 195 | static const struct nla_policy ip_tun_policy[LWTUNNEL_IP_MAX + 1] = { |
196 | [IP_TUN_ID] = { .type = NLA_U64 }, | 196 | [LWTUNNEL_IP_ID] = { .type = NLA_U64 }, |
197 | [IP_TUN_DST] = { .type = NLA_U32 }, | 197 | [LWTUNNEL_IP_DST] = { .type = NLA_U32 }, |
198 | [IP_TUN_SRC] = { .type = NLA_U32 }, | 198 | [LWTUNNEL_IP_SRC] = { .type = NLA_U32 }, |
199 | [IP_TUN_TTL] = { .type = NLA_U8 }, | 199 | [LWTUNNEL_IP_TTL] = { .type = NLA_U8 }, |
200 | [IP_TUN_TOS] = { .type = NLA_U8 }, | 200 | [LWTUNNEL_IP_TOS] = { .type = NLA_U8 }, |
201 | [IP_TUN_SPORT] = { .type = NLA_U16 }, | 201 | [LWTUNNEL_IP_SPORT] = { .type = NLA_U16 }, |
202 | [IP_TUN_DPORT] = { .type = NLA_U16 }, | 202 | [LWTUNNEL_IP_DPORT] = { .type = NLA_U16 }, |
203 | [IP_TUN_FLAGS] = { .type = NLA_U16 }, | 203 | [LWTUNNEL_IP_FLAGS] = { .type = NLA_U16 }, |
204 | }; | 204 | }; |
205 | 205 | ||
206 | static int ip_tun_build_state(struct net_device *dev, struct nlattr *attr, | 206 | static int ip_tun_build_state(struct net_device *dev, struct nlattr *attr, |
@@ -208,10 +208,10 @@ static int ip_tun_build_state(struct net_device *dev, struct nlattr *attr, | |||
208 | { | 208 | { |
209 | struct ip_tunnel_info *tun_info; | 209 | struct ip_tunnel_info *tun_info; |
210 | struct lwtunnel_state *new_state; | 210 | struct lwtunnel_state *new_state; |
211 | struct nlattr *tb[IP_TUN_MAX + 1]; | 211 | struct nlattr *tb[LWTUNNEL_IP_MAX + 1]; |
212 | int err; | 212 | int err; |
213 | 213 | ||
214 | err = nla_parse_nested(tb, IP_TUN_MAX, attr, ip_tun_policy); | 214 | err = nla_parse_nested(tb, LWTUNNEL_IP_MAX, attr, ip_tun_policy); |
215 | if (err < 0) | 215 | if (err < 0) |
216 | return err; | 216 | return err; |
217 | 217 | ||
@@ -223,29 +223,29 @@ static int ip_tun_build_state(struct net_device *dev, struct nlattr *attr, | |||
223 | 223 | ||
224 | tun_info = lwt_tun_info(new_state); | 224 | tun_info = lwt_tun_info(new_state); |
225 | 225 | ||
226 | if (tb[IP_TUN_ID]) | 226 | if (tb[LWTUNNEL_IP_ID]) |
227 | tun_info->key.tun_id = nla_get_u64(tb[IP_TUN_ID]); | 227 | tun_info->key.tun_id = nla_get_u64(tb[LWTUNNEL_IP_ID]); |
228 | 228 | ||
229 | if (tb[IP_TUN_DST]) | 229 | if (tb[LWTUNNEL_IP_DST]) |
230 | tun_info->key.ipv4_dst = nla_get_be32(tb[IP_TUN_DST]); | 230 | tun_info->key.ipv4_dst = nla_get_be32(tb[LWTUNNEL_IP_DST]); |
231 | 231 | ||
232 | if (tb[IP_TUN_SRC]) | 232 | if (tb[LWTUNNEL_IP_SRC]) |
233 | tun_info->key.ipv4_src = nla_get_be32(tb[IP_TUN_SRC]); | 233 | tun_info->key.ipv4_src = nla_get_be32(tb[LWTUNNEL_IP_SRC]); |
234 | 234 | ||
235 | if (tb[IP_TUN_TTL]) | 235 | if (tb[LWTUNNEL_IP_TTL]) |
236 | tun_info->key.ipv4_ttl = nla_get_u8(tb[IP_TUN_TTL]); | 236 | tun_info->key.ipv4_ttl = nla_get_u8(tb[LWTUNNEL_IP_TTL]); |
237 | 237 | ||
238 | if (tb[IP_TUN_TOS]) | 238 | if (tb[LWTUNNEL_IP_TOS]) |
239 | tun_info->key.ipv4_tos = nla_get_u8(tb[IP_TUN_TOS]); | 239 | tun_info->key.ipv4_tos = nla_get_u8(tb[LWTUNNEL_IP_TOS]); |
240 | 240 | ||
241 | if (tb[IP_TUN_SPORT]) | 241 | if (tb[LWTUNNEL_IP_SPORT]) |
242 | tun_info->key.tp_src = nla_get_be16(tb[IP_TUN_SPORT]); | 242 | tun_info->key.tp_src = nla_get_be16(tb[LWTUNNEL_IP_SPORT]); |
243 | 243 | ||
244 | if (tb[IP_TUN_DPORT]) | 244 | if (tb[LWTUNNEL_IP_DPORT]) |
245 | tun_info->key.tp_dst = nla_get_be16(tb[IP_TUN_DPORT]); | 245 | tun_info->key.tp_dst = nla_get_be16(tb[LWTUNNEL_IP_DPORT]); |
246 | 246 | ||
247 | if (tb[IP_TUN_FLAGS]) | 247 | if (tb[LWTUNNEL_IP_FLAGS]) |
248 | tun_info->key.tun_flags = nla_get_u16(tb[IP_TUN_FLAGS]); | 248 | tun_info->key.tun_flags = nla_get_u16(tb[LWTUNNEL_IP_FLAGS]); |
249 | 249 | ||
250 | tun_info->mode = IP_TUNNEL_INFO_TX; | 250 | tun_info->mode = IP_TUNNEL_INFO_TX; |
251 | tun_info->options = NULL; | 251 | tun_info->options = NULL; |
@@ -261,14 +261,14 @@ static int ip_tun_fill_encap_info(struct sk_buff *skb, | |||
261 | { | 261 | { |
262 | struct ip_tunnel_info *tun_info = lwt_tun_info(lwtstate); | 262 | struct ip_tunnel_info *tun_info = lwt_tun_info(lwtstate); |
263 | 263 | ||
264 | if (nla_put_u64(skb, IP_TUN_ID, tun_info->key.tun_id) || | 264 | if (nla_put_u64(skb, LWTUNNEL_IP_ID, tun_info->key.tun_id) || |
265 | nla_put_be32(skb, IP_TUN_DST, tun_info->key.ipv4_dst) || | 265 | nla_put_be32(skb, LWTUNNEL_IP_DST, tun_info->key.ipv4_dst) || |
266 | nla_put_be32(skb, IP_TUN_SRC, tun_info->key.ipv4_src) || | 266 | nla_put_be32(skb, LWTUNNEL_IP_SRC, tun_info->key.ipv4_src) || |
267 | nla_put_u8(skb, IP_TUN_TOS, tun_info->key.ipv4_tos) || | 267 | nla_put_u8(skb, LWTUNNEL_IP_TOS, tun_info->key.ipv4_tos) || |
268 | nla_put_u8(skb, IP_TUN_TTL, tun_info->key.ipv4_ttl) || | 268 | nla_put_u8(skb, LWTUNNEL_IP_TTL, tun_info->key.ipv4_ttl) || |
269 | nla_put_u16(skb, IP_TUN_SPORT, tun_info->key.tp_src) || | 269 | nla_put_u16(skb, LWTUNNEL_IP_SPORT, tun_info->key.tp_src) || |
270 | nla_put_u16(skb, IP_TUN_DPORT, tun_info->key.tp_dst) || | 270 | nla_put_u16(skb, LWTUNNEL_IP_DPORT, tun_info->key.tp_dst) || |
271 | nla_put_u16(skb, IP_TUN_FLAGS, tun_info->key.tun_flags)) | 271 | nla_put_u16(skb, LWTUNNEL_IP_FLAGS, tun_info->key.tun_flags)) |
272 | return -ENOMEM; | 272 | return -ENOMEM; |
273 | 273 | ||
274 | return 0; | 274 | return 0; |
@@ -276,14 +276,14 @@ static int ip_tun_fill_encap_info(struct sk_buff *skb, | |||
276 | 276 | ||
277 | static int ip_tun_encap_nlsize(struct lwtunnel_state *lwtstate) | 277 | static int ip_tun_encap_nlsize(struct lwtunnel_state *lwtstate) |
278 | { | 278 | { |
279 | return nla_total_size(8) /* IP_TUN_ID */ | 279 | return nla_total_size(8) /* LWTUNNEL_IP_ID */ |
280 | + nla_total_size(4) /* IP_TUN_DST */ | 280 | + nla_total_size(4) /* LWTUNNEL_IP_DST */ |
281 | + nla_total_size(4) /* IP_TUN_SRC */ | 281 | + nla_total_size(4) /* LWTUNNEL_IP_SRC */ |
282 | + nla_total_size(1) /* IP_TUN_TOS */ | 282 | + nla_total_size(1) /* LWTUNNEL_IP_TOS */ |
283 | + nla_total_size(1) /* IP_TUN_TTL */ | 283 | + nla_total_size(1) /* LWTUNNEL_IP_TTL */ |
284 | + nla_total_size(2) /* IP_TUN_SPORT */ | 284 | + nla_total_size(2) /* LWTUNNEL_IP_SPORT */ |
285 | + nla_total_size(2) /* IP_TUN_DPORT */ | 285 | + nla_total_size(2) /* LWTUNNEL_IP_DPORT */ |
286 | + nla_total_size(2); /* IP_TUN_FLAGS */ | 286 | + nla_total_size(2); /* LWTUNNEL_IP_FLAGS */ |
287 | } | 287 | } |
288 | 288 | ||
289 | static const struct lwtunnel_encap_ops ip_tun_lwt_ops = { | 289 | static const struct lwtunnel_encap_ops ip_tun_lwt_ops = { |