forked from Minki/linux
xfrm: remove eth_proto value from xfrm_state_afinfo
xfrm_prepare_input needs to lookup the state afinfo backend again to fetch the address family ethernet protocol value. There are only two address families, so a switch statement is simpler. While at it, use u8 for family and proto and remove the owner member -- its not used anywhere. Signed-off-by: Florian Westphal <fw@strlen.de> Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
This commit is contained in:
parent
3aaf3915a3
commit
4c203b0454
@ -346,10 +346,8 @@ void km_state_expired(struct xfrm_state *x, int hard, u32 portid);
|
|||||||
int __xfrm_state_delete(struct xfrm_state *x);
|
int __xfrm_state_delete(struct xfrm_state *x);
|
||||||
|
|
||||||
struct xfrm_state_afinfo {
|
struct xfrm_state_afinfo {
|
||||||
unsigned int family;
|
u8 family;
|
||||||
unsigned int proto;
|
u8 proto;
|
||||||
__be16 eth_proto;
|
|
||||||
struct module *owner;
|
|
||||||
const struct xfrm_type *type_map[IPPROTO_MAX];
|
const struct xfrm_type *type_map[IPPROTO_MAX];
|
||||||
const struct xfrm_type_offload *type_offload_map[IPPROTO_MAX];
|
const struct xfrm_type_offload *type_offload_map[IPPROTO_MAX];
|
||||||
|
|
||||||
|
@ -34,8 +34,6 @@ int xfrm4_extract_header(struct sk_buff *skb)
|
|||||||
static struct xfrm_state_afinfo xfrm4_state_afinfo = {
|
static struct xfrm_state_afinfo xfrm4_state_afinfo = {
|
||||||
.family = AF_INET,
|
.family = AF_INET,
|
||||||
.proto = IPPROTO_IPIP,
|
.proto = IPPROTO_IPIP,
|
||||||
.eth_proto = htons(ETH_P_IP),
|
|
||||||
.owner = THIS_MODULE,
|
|
||||||
.output = xfrm4_output,
|
.output = xfrm4_output,
|
||||||
.output_finish = xfrm4_output_finish,
|
.output_finish = xfrm4_output_finish,
|
||||||
.extract_input = xfrm4_extract_input,
|
.extract_input = xfrm4_extract_input,
|
||||||
|
@ -40,8 +40,6 @@ int xfrm6_extract_header(struct sk_buff *skb)
|
|||||||
static struct xfrm_state_afinfo xfrm6_state_afinfo = {
|
static struct xfrm_state_afinfo xfrm6_state_afinfo = {
|
||||||
.family = AF_INET6,
|
.family = AF_INET6,
|
||||||
.proto = IPPROTO_IPV6,
|
.proto = IPPROTO_IPV6,
|
||||||
.eth_proto = htons(ETH_P_IPV6),
|
|
||||||
.owner = THIS_MODULE,
|
|
||||||
.output = xfrm6_output,
|
.output = xfrm6_output,
|
||||||
.output_finish = xfrm6_output_finish,
|
.output_finish = xfrm6_output_finish,
|
||||||
.extract_input = xfrm6_extract_input,
|
.extract_input = xfrm6_extract_input,
|
||||||
|
@ -359,28 +359,28 @@ static int xfrm_prepare_input(struct xfrm_state *x, struct sk_buff *skb)
|
|||||||
afinfo = xfrm_state_afinfo_get_rcu(x->outer_mode.family);
|
afinfo = xfrm_state_afinfo_get_rcu(x->outer_mode.family);
|
||||||
if (likely(afinfo))
|
if (likely(afinfo))
|
||||||
err = afinfo->extract_input(x, skb);
|
err = afinfo->extract_input(x, skb);
|
||||||
|
rcu_read_unlock();
|
||||||
|
|
||||||
if (err) {
|
if (err)
|
||||||
rcu_read_unlock();
|
|
||||||
return err;
|
return err;
|
||||||
}
|
|
||||||
|
|
||||||
if (x->sel.family == AF_UNSPEC) {
|
if (x->sel.family == AF_UNSPEC) {
|
||||||
inner_mode = xfrm_ip2inner_mode(x, XFRM_MODE_SKB_CB(skb)->protocol);
|
inner_mode = xfrm_ip2inner_mode(x, XFRM_MODE_SKB_CB(skb)->protocol);
|
||||||
if (!inner_mode) {
|
if (!inner_mode)
|
||||||
rcu_read_unlock();
|
|
||||||
return -EAFNOSUPPORT;
|
return -EAFNOSUPPORT;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
afinfo = xfrm_state_afinfo_get_rcu(inner_mode->family);
|
switch (inner_mode->family) {
|
||||||
if (unlikely(!afinfo)) {
|
case AF_INET:
|
||||||
rcu_read_unlock();
|
skb->protocol = htons(ETH_P_IP);
|
||||||
return -EAFNOSUPPORT;
|
break;
|
||||||
|
case AF_INET6:
|
||||||
|
skb->protocol = htons(ETH_P_IPV6);
|
||||||
|
default:
|
||||||
|
WARN_ON_ONCE(1);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
skb->protocol = afinfo->eth_proto;
|
|
||||||
rcu_read_unlock();
|
|
||||||
return xfrm_inner_mode_encap_remove(x, inner_mode, skb);
|
return xfrm_inner_mode_encap_remove(x, inner_mode, skb);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user