Commit 5c1b9ab3 authored by Florian Westphal's avatar Florian Westphal Committed by Steffen Klassert

xfrm: remove init_temprop indirection from xfrm_state_afinfo

same as previous patch: just place this in the caller, no need to
have an indirection for a structure initialization.
Signed-off-by: default avatarFlorian Westphal <fw@strlen.de>
Signed-off-by: default avatarSteffen Klassert <steffen.klassert@secunet.com>
parent bac95935
...@@ -354,10 +354,6 @@ struct xfrm_state_afinfo { ...@@ -354,10 +354,6 @@ struct xfrm_state_afinfo {
const struct xfrm_type_offload *type_offload_map[IPPROTO_MAX]; const struct xfrm_type_offload *type_offload_map[IPPROTO_MAX];
int (*init_flags)(struct xfrm_state *x); int (*init_flags)(struct xfrm_state *x);
void (*init_temprop)(struct xfrm_state *x,
const struct xfrm_tmpl *tmpl,
const xfrm_address_t *daddr,
const xfrm_address_t *saddr);
int (*tmpl_sort)(struct xfrm_tmpl **dst, struct xfrm_tmpl **src, int n); int (*tmpl_sort)(struct xfrm_tmpl **dst, struct xfrm_tmpl **src, int n);
int (*state_sort)(struct xfrm_state **dst, struct xfrm_state **src, int n); int (*state_sort)(struct xfrm_state **dst, struct xfrm_state **src, int n);
int (*output)(struct net *net, struct sock *sk, struct sk_buff *skb); int (*output)(struct net *net, struct sock *sk, struct sk_buff *skb);
......
...@@ -22,21 +22,6 @@ static int xfrm4_init_flags(struct xfrm_state *x) ...@@ -22,21 +22,6 @@ static int xfrm4_init_flags(struct xfrm_state *x)
return 0; return 0;
} }
static void
xfrm4_init_temprop(struct xfrm_state *x, const struct xfrm_tmpl *tmpl,
const xfrm_address_t *daddr, const xfrm_address_t *saddr)
{
x->id = tmpl->id;
if (x->id.daddr.a4 == 0)
x->id.daddr.a4 = daddr->a4;
x->props.saddr = tmpl->saddr;
if (x->props.saddr.a4 == 0)
x->props.saddr.a4 = saddr->a4;
x->props.mode = tmpl->mode;
x->props.reqid = tmpl->reqid;
x->props.family = AF_INET;
}
int xfrm4_extract_header(struct sk_buff *skb) int xfrm4_extract_header(struct sk_buff *skb)
{ {
const struct iphdr *iph = ip_hdr(skb); const struct iphdr *iph = ip_hdr(skb);
...@@ -59,7 +44,6 @@ static struct xfrm_state_afinfo xfrm4_state_afinfo = { ...@@ -59,7 +44,6 @@ static struct xfrm_state_afinfo xfrm4_state_afinfo = {
.eth_proto = htons(ETH_P_IP), .eth_proto = htons(ETH_P_IP),
.owner = THIS_MODULE, .owner = THIS_MODULE,
.init_flags = xfrm4_init_flags, .init_flags = xfrm4_init_flags,
.init_temprop = xfrm4_init_temprop,
.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,
......
...@@ -21,21 +21,6 @@ ...@@ -21,21 +21,6 @@
#include <net/ipv6.h> #include <net/ipv6.h>
#include <net/addrconf.h> #include <net/addrconf.h>
static void
xfrm6_init_temprop(struct xfrm_state *x, const struct xfrm_tmpl *tmpl,
const xfrm_address_t *daddr, const xfrm_address_t *saddr)
{
x->id = tmpl->id;
if (ipv6_addr_any((struct in6_addr *)&x->id.daddr))
memcpy(&x->id.daddr, daddr, sizeof(x->sel.daddr));
memcpy(&x->props.saddr, &tmpl->saddr, sizeof(x->props.saddr));
if (ipv6_addr_any((struct in6_addr *)&x->props.saddr))
memcpy(&x->props.saddr, saddr, sizeof(x->props.saddr));
x->props.mode = tmpl->mode;
x->props.reqid = tmpl->reqid;
x->props.family = AF_INET6;
}
/* distribution counting sort function for xfrm_state and xfrm_tmpl */ /* distribution counting sort function for xfrm_state and xfrm_tmpl */
static int static int
__xfrm6_sort(void **dst, void **src, int n, int (*cmp)(void *p), int maxclass) __xfrm6_sort(void **dst, void **src, int n, int (*cmp)(void *p), int maxclass)
...@@ -153,7 +138,6 @@ static struct xfrm_state_afinfo xfrm6_state_afinfo = { ...@@ -153,7 +138,6 @@ static struct xfrm_state_afinfo xfrm6_state_afinfo = {
.proto = IPPROTO_IPV6, .proto = IPPROTO_IPV6,
.eth_proto = htons(ETH_P_IPV6), .eth_proto = htons(ETH_P_IPV6),
.owner = THIS_MODULE, .owner = THIS_MODULE,
.init_temprop = xfrm6_init_temprop,
.tmpl_sort = __xfrm6_tmpl_sort, .tmpl_sort = __xfrm6_tmpl_sort,
.state_sort = __xfrm6_state_sort, .state_sort = __xfrm6_state_sort,
.output = xfrm6_output, .output = xfrm6_output,
......
...@@ -812,8 +812,6 @@ xfrm_init_tempstate(struct xfrm_state *x, const struct flowi *fl, ...@@ -812,8 +812,6 @@ xfrm_init_tempstate(struct xfrm_state *x, const struct flowi *fl,
const xfrm_address_t *daddr, const xfrm_address_t *saddr, const xfrm_address_t *daddr, const xfrm_address_t *saddr,
unsigned short family) unsigned short family)
{ {
struct xfrm_state_afinfo *afinfo = xfrm_state_afinfo_get_rcu(family);
switch (family) { switch (family) {
case AF_INET: case AF_INET:
__xfrm4_init_tempsel(&x->sel, fl); __xfrm4_init_tempsel(&x->sel, fl);
...@@ -823,13 +821,28 @@ xfrm_init_tempstate(struct xfrm_state *x, const struct flowi *fl, ...@@ -823,13 +821,28 @@ xfrm_init_tempstate(struct xfrm_state *x, const struct flowi *fl,
break; break;
} }
if (family != tmpl->encap_family) x->id = tmpl->id;
afinfo = xfrm_state_afinfo_get_rcu(tmpl->encap_family);
if (!afinfo) switch (tmpl->encap_family) {
return; case AF_INET:
if (x->id.daddr.a4 == 0)
x->id.daddr.a4 = daddr->a4;
x->props.saddr = tmpl->saddr;
if (x->props.saddr.a4 == 0)
x->props.saddr.a4 = saddr->a4;
break;
case AF_INET6:
if (ipv6_addr_any((struct in6_addr *)&x->id.daddr))
memcpy(&x->id.daddr, daddr, sizeof(x->sel.daddr));
memcpy(&x->props.saddr, &tmpl->saddr, sizeof(x->props.saddr));
if (ipv6_addr_any((struct in6_addr *)&x->props.saddr))
memcpy(&x->props.saddr, saddr, sizeof(x->props.saddr));
break;
}
afinfo->init_temprop(x, tmpl, daddr, saddr); x->props.mode = tmpl->mode;
x->props.reqid = tmpl->reqid;
x->props.family = tmpl->encap_family;
} }
static struct xfrm_state *__xfrm_state_lookup(struct net *net, u32 mark, static struct xfrm_state *__xfrm_state_lookup(struct net *net, u32 mark,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment