Skip to content

Commit 8359925

Browse files
yasuyuki5David S. Miller
authored andcommitted
[IPV6] IP6TUNNEL: Split out generic routine in ip6ip6_rcv().
This enables to add IPv4/IPv6 specific handling later, Signed-off-by: Yasuyuki Kozakai <[email protected]> Signed-off-by: YOSHIFUJI Hideaki <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent e490d1d commit 8359925

File tree

1 file changed

+23
-11
lines changed

1 file changed

+23
-11
lines changed

net/ipv6/ip6_tunnel.c

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -513,14 +513,17 @@ ip6ip6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
513513
return 0;
514514
}
515515

516-
static inline void ip6ip6_ecn_decapsulate(struct ipv6hdr *outer_iph,
517-
struct sk_buff *skb)
516+
static void ip6ip6_dscp_ecn_decapsulate(struct ip6_tnl *t,
517+
struct ipv6hdr *ipv6h,
518+
struct sk_buff *skb)
518519
{
519-
struct ipv6hdr *inner_iph = skb->nh.ipv6h;
520+
if (t->parms.flags & IP6_TNL_F_RCV_DSCP_COPY)
521+
ipv6_copy_dscp(ipv6h, skb->nh.ipv6h);
520522

521-
if (INET_ECN_is_ce(ipv6_get_dsfield(outer_iph)))
522-
IP6_ECN_set_ce(inner_iph);
523+
if (INET_ECN_is_ce(ipv6_get_dsfield(ipv6h)))
524+
IP6_ECN_set_ce(skb->nh.ipv6h);
523525
}
526+
524527
static inline int ip6_tnl_rcv_ctl(struct ip6_tnl *t)
525528
{
526529
struct ip6_tnl_parm *p = &t->parms;
@@ -546,12 +549,16 @@ static inline int ip6_tnl_rcv_ctl(struct ip6_tnl *t)
546549
/**
547550
* ip6ip6_rcv - decapsulate IPv6 packet and retransmit it locally
548551
* @skb: received socket buffer
552+
* @protocol: ethernet protocol ID
553+
* @dscp_ecn_decapsulate: the function to decapsulate DSCP code and ECN
549554
*
550555
* Return: 0
551556
**/
552557

553-
static int
554-
ip6ip6_rcv(struct sk_buff *skb)
558+
static int ip6_tnl_rcv(struct sk_buff *skb, __u16 protocol,
559+
void (*dscp_ecn_decapsulate)(struct ip6_tnl *t,
560+
struct ipv6hdr *ipv6h,
561+
struct sk_buff *skb))
555562
{
556563
struct ipv6hdr *ipv6h;
557564
struct ip6_tnl *t;
@@ -574,16 +581,16 @@ ip6ip6_rcv(struct sk_buff *skb)
574581
secpath_reset(skb);
575582
skb->mac.raw = skb->nh.raw;
576583
skb->nh.raw = skb->data;
577-
skb->protocol = htons(ETH_P_IPV6);
584+
skb->protocol = htons(protocol);
578585
skb->pkt_type = PACKET_HOST;
579586
memset(skb->cb, 0, sizeof(struct inet6_skb_parm));
580587
skb->dev = t->dev;
581588
dst_release(skb->dst);
582589
skb->dst = NULL;
583590
nf_reset(skb);
584-
if (t->parms.flags & IP6_TNL_F_RCV_DSCP_COPY)
585-
ipv6_copy_dscp(ipv6h, skb->nh.ipv6h);
586-
ip6ip6_ecn_decapsulate(ipv6h, skb);
591+
592+
dscp_ecn_decapsulate(t, ipv6h, skb);
593+
587594
t->stat.rx_packets++;
588595
t->stat.rx_bytes += skb->len;
589596
netif_rx(skb);
@@ -598,6 +605,11 @@ ip6ip6_rcv(struct sk_buff *skb)
598605
return 0;
599606
}
600607

608+
static int ip6ip6_rcv(struct sk_buff *skb)
609+
{
610+
return ip6_tnl_rcv(skb, ETH_P_IPV6, ip6ip6_dscp_ecn_decapsulate);
611+
}
612+
601613
struct ipv6_tel_txoption {
602614
struct ipv6_txoptions ops;
603615
__u8 dst_opt[8];

0 commit comments

Comments
 (0)