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

ila: allow configuration of identifier type

Allow identifier to be explicitly configured for a mapping.
This can either be one of the identifier types specified in the
ILA draft or a value of ILA_ATYPE_USE_FORMAT which means the
identifier type is inferred from the identifier type field.
If a value other than ILA_ATYPE_USE_FORMAT is set for a
mapping then it is assumed that the identifier type field is
not present in an identifier.

Signed-off-by: Tom Herbert <tom@quantonium.net>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Tom Herbert and committed by
David S. Miller
70d5aef4 84287bb3

+71 -23
+13
include/uapi/linux/ila.h
··· 17 17 ILA_ATTR_DIR, /* u32 */ 18 18 ILA_ATTR_PAD, 19 19 ILA_ATTR_CSUM_MODE, /* u8 */ 20 + ILA_ATTR_IDENT_TYPE, /* u8 */ 20 21 21 22 __ILA_ATTR_MAX, 22 23 }; ··· 45 44 ILA_CSUM_NEUTRAL_MAP_AUTO, 46 45 }; 47 46 47 + enum { 48 + ILA_ATYPE_IID = 0, 49 + ILA_ATYPE_LUID, 50 + ILA_ATYPE_VIRT_V4, 51 + ILA_ATYPE_VIRT_UNI_V6, 52 + ILA_ATYPE_VIRT_MULTI_V6, 53 + ILA_ATYPE_NONLOCAL_ADDR, 54 + ILA_ATYPE_RSVD_1, 55 + ILA_ATYPE_RSVD_2, 56 + 57 + ILA_ATYPE_USE_FORMAT = 32, /* Get type from type field in identifier */ 58 + }; 48 59 #endif /* _UAPI_LINUX_ILA_H */
+1 -11
net/ipv6/ila/ila.h
··· 55 55 }; 56 56 }; 57 57 58 - enum { 59 - ILA_ATYPE_IID = 0, 60 - ILA_ATYPE_LUID, 61 - ILA_ATYPE_VIRT_V4, 62 - ILA_ATYPE_VIRT_UNI_V6, 63 - ILA_ATYPE_VIRT_MULTI_V6, 64 - ILA_ATYPE_RSVD_1, 65 - ILA_ATYPE_RSVD_2, 66 - ILA_ATYPE_RSVD_3, 67 - }; 68 - 69 58 #define CSUM_NEUTRAL_FLAG htonl(0x10000000) 70 59 71 60 struct ila_addr { ··· 82 93 struct ila_locator locator_match; 83 94 __wsum csum_diff; 84 95 u8 csum_mode; 96 + u8 ident_type; 85 97 }; 86 98 87 99 static inline __wsum compute_csum_diff8(const __be32 *from, const __be32 *to)
+44 -7
net/ipv6/ila/ila_lwt.c
··· 114 114 static const struct nla_policy ila_nl_policy[ILA_ATTR_MAX + 1] = { 115 115 [ILA_ATTR_LOCATOR] = { .type = NLA_U64, }, 116 116 [ILA_ATTR_CSUM_MODE] = { .type = NLA_U8, }, 117 + [ILA_ATTR_IDENT_TYPE] = { .type = NLA_U8, }, 117 118 }; 118 119 119 120 static int ila_build_state(struct nlattr *nla, ··· 128 127 struct lwtunnel_state *newts; 129 128 const struct fib6_config *cfg6 = cfg; 130 129 struct ila_addr *iaddr; 130 + u8 ident_type = ILA_ATYPE_USE_FORMAT; 131 131 u8 csum_mode = ILA_CSUM_NO_ACTION; 132 + u8 eff_ident_type; 132 133 int ret; 133 134 134 135 if (family != AF_INET6) 135 136 return -EINVAL; 136 - 137 - if (cfg6->fc_dst_len < 8 * sizeof(struct ila_locator) + 3) { 138 - /* Need to have full locator and at least type field 139 - * included in destination 140 - */ 141 - return -EINVAL; 142 - } 143 137 144 138 ret = nla_parse_nested(tb, ILA_ATTR_MAX, nla, ila_nl_policy, extack); 145 139 if (ret < 0) ··· 144 148 return -EINVAL; 145 149 146 150 iaddr = (struct ila_addr *)&cfg6->fc_dst; 151 + 152 + if (tb[ILA_ATTR_IDENT_TYPE]) 153 + ident_type = nla_get_u8(tb[ILA_ATTR_IDENT_TYPE]); 154 + 155 + if (ident_type == ILA_ATYPE_USE_FORMAT) { 156 + /* Infer identifier type from type field in formatted 157 + * identifier. 158 + */ 159 + 160 + if (cfg6->fc_dst_len < 8 * sizeof(struct ila_locator) + 3) { 161 + /* Need to have full locator and at least type field 162 + * included in destination 163 + */ 164 + return -EINVAL; 165 + } 166 + 167 + eff_ident_type = iaddr->ident.type; 168 + } else { 169 + eff_ident_type = ident_type; 170 + } 171 + 172 + switch (eff_ident_type) { 173 + case ILA_ATYPE_IID: 174 + /* Don't allow ILA for IID type */ 175 + return -EINVAL; 176 + case ILA_ATYPE_LUID: 177 + break; 178 + case ILA_ATYPE_VIRT_V4: 179 + case ILA_ATYPE_VIRT_UNI_V6: 180 + case ILA_ATYPE_VIRT_MULTI_V6: 181 + case ILA_ATYPE_NONLOCAL_ADDR: 182 + /* These ILA formats are not supported yet. */ 183 + default: 184 + return -EINVAL; 185 + } 147 186 148 187 if (tb[ILA_ATTR_CSUM_MODE]) 149 188 csum_mode = nla_get_u8(tb[ILA_ATTR_CSUM_MODE]); ··· 205 174 p = ila_params_lwtunnel(newts); 206 175 207 176 p->csum_mode = csum_mode; 177 + p->ident_type = ident_type; 208 178 p->locator.v64 = (__force __be64)nla_get_u64(tb[ILA_ATTR_LOCATOR]); 209 179 210 180 /* Precompute checksum difference for translation since we ··· 240 208 if (nla_put_u64_64bit(skb, ILA_ATTR_LOCATOR, (__force u64)p->locator.v64, 241 209 ILA_ATTR_PAD)) 242 210 goto nla_put_failure; 211 + 243 212 if (nla_put_u8(skb, ILA_ATTR_CSUM_MODE, (__force u8)p->csum_mode)) 213 + goto nla_put_failure; 214 + 215 + if (nla_put_u8(skb, ILA_ATTR_IDENT_TYPE, (__force u8)p->ident_type)) 244 216 goto nla_put_failure; 245 217 246 218 return 0; ··· 257 221 { 258 222 return nla_total_size_64bit(sizeof(u64)) + /* ILA_ATTR_LOCATOR */ 259 223 nla_total_size(sizeof(u8)) + /* ILA_ATTR_CSUM_MODE */ 224 + nla_total_size(sizeof(u8)) + /* ILA_ATTR_IDENT_TYPE */ 260 225 0; 261 226 } 262 227
+13 -5
net/ipv6/ila/ila_xlat.c
··· 121 121 [ILA_ATTR_LOCATOR_MATCH] = { .type = NLA_U64, }, 122 122 [ILA_ATTR_IFINDEX] = { .type = NLA_U32, }, 123 123 [ILA_ATTR_CSUM_MODE] = { .type = NLA_U8, }, 124 + [ILA_ATTR_IDENT_TYPE] = { .type = NLA_U8, }, 124 125 }; 125 126 126 127 static int parse_nl_config(struct genl_info *info, ··· 141 140 xp->ip.csum_mode = nla_get_u8(info->attrs[ILA_ATTR_CSUM_MODE]); 142 141 else 143 142 xp->ip.csum_mode = ILA_CSUM_NO_ACTION; 143 + 144 + if (info->attrs[ILA_ATTR_IDENT_TYPE]) 145 + xp->ip.ident_type = nla_get_u8( 146 + info->attrs[ILA_ATTR_IDENT_TYPE]); 147 + else 148 + xp->ip.ident_type = ILA_ATYPE_USE_FORMAT; 144 149 145 150 if (info->attrs[ILA_ATTR_IFINDEX]) 146 151 xp->ifindex = nla_get_s32(info->attrs[ILA_ATTR_IFINDEX]); ··· 405 398 (__force u64)ila->xp.ip.locator_match.v64, 406 399 ILA_ATTR_PAD) || 407 400 nla_put_s32(msg, ILA_ATTR_IFINDEX, ila->xp.ifindex) || 408 - nla_put_u8(msg, ILA_ATTR_CSUM_MODE, ila->xp.ip.csum_mode)) 401 + nla_put_u8(msg, ILA_ATTR_CSUM_MODE, ila->xp.ip.csum_mode) || 402 + nla_put_u8(msg, ILA_ATTR_IDENT_TYPE, ila->xp.ip.ident_type)) 409 403 return -1; 410 404 411 405 return 0; ··· 627 619 628 620 /* Assumes skb contains a valid IPv6 header that is pulled */ 629 621 630 - if (!ila_addr_is_ila(iaddr)) { 631 - /* Type indicates this is not an ILA address */ 632 - return 0; 633 - } 622 + /* No check here that ILA type in the mapping matches what is in the 623 + * address. We assume that whatever sender gaves us can be translated. 624 + * The checksum mode however is relevant. 625 + */ 634 626 635 627 rcu_read_lock(); 636 628