76 lines
2.0 KiB
C
Executable File
76 lines
2.0 KiB
C
Executable File
#ifndef _LINUX_ECNT_VLAN_H
|
|
#define _LINUX_ECNT_VLAN_H
|
|
#include <linux/skbuff.h>
|
|
#include <linux/netdevice.h>
|
|
#include <linux/if_vlan.h>
|
|
#include <linux/netpoll.h>
|
|
#include <linux/export.h>
|
|
#include <ecnt_hook/ecnt_hook.h>
|
|
|
|
#if defined(TCSUPPORT_CT_VLAN_TAG)
|
|
extern unsigned int vtag_free_rx_cnt;
|
|
extern int (*check_vtag_ct_hook)(void);
|
|
extern int (*store_vtag_ct_hook)(struct sk_buff *skb, struct net_device *dev);
|
|
#endif
|
|
|
|
extern struct sk_buff *skb_reorder_vlan_header(struct sk_buff *skb);
|
|
|
|
static inline int isBridgeWan(struct net_device *dev)
|
|
{
|
|
if (dev == NULL)
|
|
return 0;
|
|
|
|
if (rcu_dereference(dev->rx_handler_data) == NULL)
|
|
return 0;
|
|
|
|
return 1;
|
|
}
|
|
|
|
static inline int ecnt_vlan_receive_inline_hook(struct sk_buff **skbp, __be16 vlan_proto)
|
|
{
|
|
struct sk_buff *skb = *skbp;
|
|
unsigned int offset = skb->data - skb_mac_header(skb);
|
|
/*
|
|
* vlan_insert_tag expect skb->data pointing to mac header.
|
|
* So change skb->data before calling it and change back to
|
|
* original position later
|
|
*/
|
|
skb_push(skb, offset);
|
|
skb = *skbp = vlan_insert_tag(skb, skb->vlan_proto,
|
|
vlan_tx_tag_get(skb));
|
|
if (!skb)
|
|
return ECNT_CONTINUE;
|
|
skb->vlan_tci = 0;
|
|
skb->protocol = vlan_proto;
|
|
skb_pull(skb, offset);
|
|
|
|
#if defined(TCSUPPORT_CT_VLAN_TAG)
|
|
/*remove vlan tag from packet, store vlan tag to skb structure*/
|
|
struct net_device * orig_dev = skb->dev;
|
|
if((orig_dev->name[0] == 'b') || ((orig_dev->name[0] == 'n') && !isBridgeWan(orig_dev))){
|
|
if (check_vtag_ct_hook && (check_vtag_ct_hook() == 1)
|
|
&& store_vtag_ct_hook){
|
|
if( store_vtag_ct_hook(skb, orig_dev)== 0){
|
|
/* Take off the VLAN header (4 bytes currently) */
|
|
skb_pull_rcsum(skb, VLAN_HLEN);
|
|
skb = *skbp = skb_reorder_vlan_header(skb);
|
|
if (unlikely(!skb))
|
|
return ECNT_CONTINUE;
|
|
skb->dev = orig_dev;
|
|
return ECNT_RETURN; /*return true*/
|
|
}else{
|
|
/* must free skb !! */
|
|
vtag_free_rx_cnt++;
|
|
return ECNT_CONTINUE;
|
|
}
|
|
}
|
|
}
|
|
#endif
|
|
|
|
return ECNT_CONTINUE;
|
|
}
|
|
|
|
|
|
#endif
|
|
|