Skip to content

Commit f479639

Browse files
herbertxklassert
authored andcommitted
xfrm: Remove inner/outer modes from output path
The inner/outer modes were added to abstract out common code that were once duplicated between IPv4 and IPv6. As time went on the abstractions have been removed and we are now left with empty shells that only contain duplicate information. These can be removed one-by-one as the same information is already present elsewhere in the xfrm_state object. Just like the input-side, removing this from the output code makes it possible to use transport-mode SAs underneath an inter-family tunnel mode SA. Signed-off-by: Herbert Xu <[email protected]> Signed-off-by: Steffen Klassert <[email protected]>
1 parent 5f24f41 commit f479639

File tree

1 file changed

+11
-22
lines changed

1 file changed

+11
-22
lines changed

net/xfrm/xfrm_output.c

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ static int xfrm4_prepare_output(struct xfrm_state *x, struct sk_buff *skb)
412412
IPCB(skb)->flags |= IPSKB_XFRM_TUNNEL_SIZE;
413413
skb->protocol = htons(ETH_P_IP);
414414

415-
switch (x->outer_mode.encap) {
415+
switch (x->props.mode) {
416416
case XFRM_MODE_BEET:
417417
return xfrm4_beet_encap_add(x, skb);
418418
case XFRM_MODE_TUNNEL:
@@ -435,7 +435,7 @@ static int xfrm6_prepare_output(struct xfrm_state *x, struct sk_buff *skb)
435435
skb->ignore_df = 1;
436436
skb->protocol = htons(ETH_P_IPV6);
437437

438-
switch (x->outer_mode.encap) {
438+
switch (x->props.mode) {
439439
case XFRM_MODE_BEET:
440440
return xfrm6_beet_encap_add(x, skb);
441441
case XFRM_MODE_TUNNEL:
@@ -451,22 +451,22 @@ static int xfrm6_prepare_output(struct xfrm_state *x, struct sk_buff *skb)
451451

452452
static int xfrm_outer_mode_output(struct xfrm_state *x, struct sk_buff *skb)
453453
{
454-
switch (x->outer_mode.encap) {
454+
switch (x->props.mode) {
455455
case XFRM_MODE_BEET:
456456
case XFRM_MODE_TUNNEL:
457-
if (x->outer_mode.family == AF_INET)
457+
if (x->props.family == AF_INET)
458458
return xfrm4_prepare_output(x, skb);
459-
if (x->outer_mode.family == AF_INET6)
459+
if (x->props.family == AF_INET6)
460460
return xfrm6_prepare_output(x, skb);
461461
break;
462462
case XFRM_MODE_TRANSPORT:
463-
if (x->outer_mode.family == AF_INET)
463+
if (x->props.family == AF_INET)
464464
return xfrm4_transport_output(x, skb);
465-
if (x->outer_mode.family == AF_INET6)
465+
if (x->props.family == AF_INET6)
466466
return xfrm6_transport_output(x, skb);
467467
break;
468468
case XFRM_MODE_ROUTEOPTIMIZATION:
469-
if (x->outer_mode.family == AF_INET6)
469+
if (x->props.family == AF_INET6)
470470
return xfrm6_ro_output(x, skb);
471471
WARN_ON_ONCE(1);
472472
break;
@@ -875,21 +875,10 @@ static int xfrm6_extract_output(struct xfrm_state *x, struct sk_buff *skb)
875875

876876
static int xfrm_inner_extract_output(struct xfrm_state *x, struct sk_buff *skb)
877877
{
878-
const struct xfrm_mode *inner_mode;
879-
880-
if (x->sel.family == AF_UNSPEC)
881-
inner_mode = xfrm_ip2inner_mode(x,
882-
xfrm_af2proto(skb_dst(skb)->ops->family));
883-
else
884-
inner_mode = &x->inner_mode;
885-
886-
if (inner_mode == NULL)
887-
return -EAFNOSUPPORT;
888-
889-
switch (inner_mode->family) {
890-
case AF_INET:
878+
switch (skb->protocol) {
879+
case htons(ETH_P_IP):
891880
return xfrm4_extract_output(x, skb);
892-
case AF_INET6:
881+
case htons(ETH_P_IPV6):
893882
return xfrm6_extract_output(x, skb);
894883
}
895884

0 commit comments

Comments
 (0)