@@ -114,7 +114,8 @@ MODULE_PARM_DESC(log_ecn_error, "Log packets received with corrupted ECN");
114
114
static struct rtnl_link_ops ipgre_link_ops __read_mostly ;
115
115
static int ipgre_tunnel_init (struct net_device * dev );
116
116
static void erspan_build_header (struct sk_buff * skb ,
117
- __be32 id , u32 index , bool truncate );
117
+ __be32 id , u32 index ,
118
+ bool truncate , bool is_ipv4 );
118
119
119
120
static unsigned int ipgre_net_id __read_mostly ;
120
121
static unsigned int gre_tap_net_id __read_mostly ;
@@ -589,7 +590,7 @@ static void erspan_fb_xmit(struct sk_buff *skb, struct net_device *dev,
589
590
goto err_free_rt ;
590
591
591
592
erspan_build_header (skb , tunnel_id_to_key32 (key -> tun_id ),
592
- ntohl (md -> index ), truncate );
593
+ ntohl (md -> index ), truncate , true );
593
594
594
595
gre_build_header (skb , 8 , TUNNEL_SEQ ,
595
596
htons (ETH_P_ERSPAN ), 0 , htonl (tunnel -> o_seqno ++ ));
@@ -668,52 +669,6 @@ static netdev_tx_t ipgre_xmit(struct sk_buff *skb,
668
669
return NETDEV_TX_OK ;
669
670
}
670
671
671
- static inline u8 tos_to_cos (u8 tos )
672
- {
673
- u8 dscp , cos ;
674
-
675
- dscp = tos >> 2 ;
676
- cos = dscp >> 3 ;
677
- return cos ;
678
- }
679
-
680
- static void erspan_build_header (struct sk_buff * skb ,
681
- __be32 id , u32 index , bool truncate )
682
- {
683
- struct iphdr * iphdr = ip_hdr (skb );
684
- struct ethhdr * eth = eth_hdr (skb );
685
- enum erspan_encap_type enc_type ;
686
- struct erspanhdr * ershdr ;
687
- struct qtag_prefix {
688
- __be16 eth_type ;
689
- __be16 tci ;
690
- } * qp ;
691
- u16 vlan_tci = 0 ;
692
-
693
- enc_type = ERSPAN_ENCAP_NOVLAN ;
694
-
695
- /* If mirrored packet has vlan tag, extract tci and
696
- * perserve vlan header in the mirrored frame.
697
- */
698
- if (eth -> h_proto == htons (ETH_P_8021Q )) {
699
- qp = (struct qtag_prefix * )(skb -> data + 2 * ETH_ALEN );
700
- vlan_tci = ntohs (qp -> tci );
701
- enc_type = ERSPAN_ENCAP_INFRAME ;
702
- }
703
-
704
- skb_push (skb , sizeof (* ershdr ));
705
- ershdr = (struct erspanhdr * )skb -> data ;
706
- memset (ershdr , 0 , sizeof (* ershdr ));
707
-
708
- ershdr -> ver_vlan = htons ((vlan_tci & VLAN_MASK ) |
709
- (ERSPAN_VERSION << VER_OFFSET ));
710
- ershdr -> session_id = htons ((u16 )(ntohl (id ) & ID_MASK ) |
711
- ((tos_to_cos (iphdr -> tos ) << COS_OFFSET ) & COS_MASK ) |
712
- (enc_type << EN_OFFSET & EN_MASK ) |
713
- ((truncate << T_OFFSET ) & T_MASK ));
714
- ershdr -> md .index = htonl (index & INDEX_MASK );
715
- }
716
-
717
672
static netdev_tx_t erspan_xmit (struct sk_buff * skb ,
718
673
struct net_device * dev )
719
674
{
@@ -737,7 +692,8 @@ static netdev_tx_t erspan_xmit(struct sk_buff *skb,
737
692
}
738
693
739
694
/* Push ERSPAN header */
740
- erspan_build_header (skb , tunnel -> parms .o_key , tunnel -> index , truncate );
695
+ erspan_build_header (skb , tunnel -> parms .o_key , tunnel -> index ,
696
+ truncate , true);
741
697
tunnel -> parms .o_flags &= ~TUNNEL_KEY ;
742
698
__gre_xmit (skb , dev , & tunnel -> parms .iph , htons (ETH_P_ERSPAN ));
743
699
return NETDEV_TX_OK ;
0 commit comments