Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Jiri Benc and committed by
David S. Miller
a1c234f9 62ee783b

+57 -58
+14
include/uapi/linux/lwtunnel.h
··· 12 12 13 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 30 #endif /* _UAPI_LWTUNNEL_H_ */
-15
include/uapi/linux/rtnetlink.h
··· 286 286 287 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 289 enum rtattr_type_t { 305 290 RTA_UNSPEC, 306 291 RTA_DST,
+43 -43
net/ipv4/ip_tunnel_core.c
··· 192 192 } 193 193 EXPORT_SYMBOL_GPL(ip_tunnel_get_stats64); 194 194 195 - static const struct nla_policy ip_tun_policy[IP_TUN_MAX + 1] = { 196 - [IP_TUN_ID] = { .type = NLA_U64 }, 197 - [IP_TUN_DST] = { .type = NLA_U32 }, 198 - [IP_TUN_SRC] = { .type = NLA_U32 }, 199 - [IP_TUN_TTL] = { .type = NLA_U8 }, 200 - [IP_TUN_TOS] = { .type = NLA_U8 }, 201 - [IP_TUN_SPORT] = { .type = NLA_U16 }, 202 - [IP_TUN_DPORT] = { .type = NLA_U16 }, 203 - [IP_TUN_FLAGS] = { .type = NLA_U16 }, 195 + static const struct nla_policy ip_tun_policy[LWTUNNEL_IP_MAX + 1] = { 196 + [LWTUNNEL_IP_ID] = { .type = NLA_U64 }, 197 + [LWTUNNEL_IP_DST] = { .type = NLA_U32 }, 198 + [LWTUNNEL_IP_SRC] = { .type = NLA_U32 }, 199 + [LWTUNNEL_IP_TTL] = { .type = NLA_U8 }, 200 + [LWTUNNEL_IP_TOS] = { .type = NLA_U8 }, 201 + [LWTUNNEL_IP_SPORT] = { .type = NLA_U16 }, 202 + [LWTUNNEL_IP_DPORT] = { .type = NLA_U16 }, 203 + [LWTUNNEL_IP_FLAGS] = { .type = NLA_U16 }, 204 204 }; 205 205 206 206 static int ip_tun_build_state(struct net_device *dev, struct nlattr *attr, ··· 208 208 { 209 209 struct ip_tunnel_info *tun_info; 210 210 struct lwtunnel_state *new_state; 211 - struct nlattr *tb[IP_TUN_MAX + 1]; 211 + struct nlattr *tb[LWTUNNEL_IP_MAX + 1]; 212 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 215 if (err < 0) 216 216 return err; 217 217 ··· 223 223 224 224 tun_info = lwt_tun_info(new_state); 225 225 226 - if (tb[IP_TUN_ID]) 227 - tun_info->key.tun_id = nla_get_u64(tb[IP_TUN_ID]); 226 + if (tb[LWTUNNEL_IP_ID]) 227 + tun_info->key.tun_id = nla_get_u64(tb[LWTUNNEL_IP_ID]); 228 228 229 - if (tb[IP_TUN_DST]) 230 - tun_info->key.ipv4_dst = nla_get_be32(tb[IP_TUN_DST]); 229 + if (tb[LWTUNNEL_IP_DST]) 230 + tun_info->key.ipv4_dst = nla_get_be32(tb[LWTUNNEL_IP_DST]); 231 231 232 - if (tb[IP_TUN_SRC]) 233 - tun_info->key.ipv4_src = nla_get_be32(tb[IP_TUN_SRC]); 232 + if (tb[LWTUNNEL_IP_SRC]) 233 + tun_info->key.ipv4_src = nla_get_be32(tb[LWTUNNEL_IP_SRC]); 234 234 235 - if (tb[IP_TUN_TTL]) 236 - tun_info->key.ipv4_ttl = nla_get_u8(tb[IP_TUN_TTL]); 235 + if (tb[LWTUNNEL_IP_TTL]) 236 + tun_info->key.ipv4_ttl = nla_get_u8(tb[LWTUNNEL_IP_TTL]); 237 237 238 - if (tb[IP_TUN_TOS]) 239 - tun_info->key.ipv4_tos = nla_get_u8(tb[IP_TUN_TOS]); 238 + if (tb[LWTUNNEL_IP_TOS]) 239 + tun_info->key.ipv4_tos = nla_get_u8(tb[LWTUNNEL_IP_TOS]); 240 240 241 - if (tb[IP_TUN_SPORT]) 242 - tun_info->key.tp_src = nla_get_be16(tb[IP_TUN_SPORT]); 241 + if (tb[LWTUNNEL_IP_SPORT]) 242 + tun_info->key.tp_src = nla_get_be16(tb[LWTUNNEL_IP_SPORT]); 243 243 244 - if (tb[IP_TUN_DPORT]) 245 - tun_info->key.tp_dst = nla_get_be16(tb[IP_TUN_DPORT]); 244 + if (tb[LWTUNNEL_IP_DPORT]) 245 + tun_info->key.tp_dst = nla_get_be16(tb[LWTUNNEL_IP_DPORT]); 246 246 247 - if (tb[IP_TUN_FLAGS]) 248 - tun_info->key.tun_flags = nla_get_u16(tb[IP_TUN_FLAGS]); 247 + if (tb[LWTUNNEL_IP_FLAGS]) 248 + tun_info->key.tun_flags = nla_get_u16(tb[LWTUNNEL_IP_FLAGS]); 249 249 250 250 tun_info->mode = IP_TUNNEL_INFO_TX; 251 251 tun_info->options = NULL; ··· 261 261 { 262 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) || 265 - nla_put_be32(skb, IP_TUN_DST, tun_info->key.ipv4_dst) || 266 - nla_put_be32(skb, IP_TUN_SRC, tun_info->key.ipv4_src) || 267 - nla_put_u8(skb, IP_TUN_TOS, tun_info->key.ipv4_tos) || 268 - nla_put_u8(skb, IP_TUN_TTL, tun_info->key.ipv4_ttl) || 269 - nla_put_u16(skb, IP_TUN_SPORT, tun_info->key.tp_src) || 270 - nla_put_u16(skb, IP_TUN_DPORT, tun_info->key.tp_dst) || 271 - nla_put_u16(skb, IP_TUN_FLAGS, tun_info->key.tun_flags)) 264 + if (nla_put_u64(skb, LWTUNNEL_IP_ID, tun_info->key.tun_id) || 265 + nla_put_be32(skb, LWTUNNEL_IP_DST, tun_info->key.ipv4_dst) || 266 + nla_put_be32(skb, LWTUNNEL_IP_SRC, tun_info->key.ipv4_src) || 267 + nla_put_u8(skb, LWTUNNEL_IP_TOS, tun_info->key.ipv4_tos) || 268 + nla_put_u8(skb, LWTUNNEL_IP_TTL, tun_info->key.ipv4_ttl) || 269 + nla_put_u16(skb, LWTUNNEL_IP_SPORT, tun_info->key.tp_src) || 270 + nla_put_u16(skb, LWTUNNEL_IP_DPORT, tun_info->key.tp_dst) || 271 + nla_put_u16(skb, LWTUNNEL_IP_FLAGS, tun_info->key.tun_flags)) 272 272 return -ENOMEM; 273 273 274 274 return 0; ··· 276 276 277 277 static int ip_tun_encap_nlsize(struct lwtunnel_state *lwtstate) 278 278 { 279 - return nla_total_size(8) /* IP_TUN_ID */ 280 - + nla_total_size(4) /* IP_TUN_DST */ 281 - + nla_total_size(4) /* IP_TUN_SRC */ 282 - + nla_total_size(1) /* IP_TUN_TOS */ 283 - + nla_total_size(1) /* IP_TUN_TTL */ 284 - + nla_total_size(2) /* IP_TUN_SPORT */ 285 - + nla_total_size(2) /* IP_TUN_DPORT */ 286 - + nla_total_size(2); /* IP_TUN_FLAGS */ 279 + return nla_total_size(8) /* LWTUNNEL_IP_ID */ 280 + + nla_total_size(4) /* LWTUNNEL_IP_DST */ 281 + + nla_total_size(4) /* LWTUNNEL_IP_SRC */ 282 + + nla_total_size(1) /* LWTUNNEL_IP_TOS */ 283 + + nla_total_size(1) /* LWTUNNEL_IP_TTL */ 284 + + nla_total_size(2) /* LWTUNNEL_IP_SPORT */ 285 + + nla_total_size(2) /* LWTUNNEL_IP_DPORT */ 286 + + nla_total_size(2); /* LWTUNNEL_IP_FLAGS */ 287 287 } 288 288 289 289 static const struct lwtunnel_encap_ops ip_tun_lwt_ops = {