* Vlan modifications
@ 2011-09-28 1:28 Augusto Salazar
0 siblings, 0 replies; only message in thread
From: Augusto Salazar @ 2011-09-28 1:28 UTC (permalink / raw)
To: netfilter
Greetings,
I am working on a kernel module that uses netfilter to catch packets, modify
its vlan tag or remove it or even add one, all depending on the user input.
I am able to catch the packets like this:
netfilter_ops.hook =
main_hook;
netfilter_ops.pf =
PF_INET;
netfilter_ops.hooknum =
NF_IP_PRE_ROUTING;
netfilter_ops.priority =
NF_IP_PRI_FIRST;
err = nf_register_hook(&netfilter_ops);
It is working fine.
The issue I have is the following:
The vlan headers on other parts of the kernel are managed the data field of
the skb, for example:
static inline int thesis_vlan_get_tag(struct sk_buff *skb)
{
struct vlan_ethhdr *veth = (struct vlan_ethhdr *)skb->data;
unsigned short tag;
if (veth->h_vlan_proto != __constant_htons(ETH_P_8021Q)) {
printk("\n thesis_vlan_get_tag no Vlan\n");
return -EINVAL;
}
tag = ntohs(veth->h_vlan_TCI);
printk("\n thesis_vlan_get_tag VID2 %d\n",tag);
return 0;
}
But, on the skb that I get that info is actually on the raw of the mac, so
to print the vlan I have to do this:
static inline int thesis_vlan_get_tag2(struct sk_buff *skb)
{
struct vlan_ethhdr *veth = (struct vlan_ethhdr *)skb->mac.raw;
unsigned short tag;
if (veth->h_vlan_proto != __constant_htons(ETH_P_8021Q)) {
printk("\n thesis_vlan_get_tag2 no Vlan\n");
return -EINVAL;
}
tag = ntohs(veth->h_vlan_TCI) & VLAN_VID_MASK;
printk("\n thesis_vlan_get_tag VID2 %d\n",tag);
return 0;
}
Can someone explain me why? I would like to reuse some of the kernel
functions but they all use the data field.
I use linux-2.6.20 on a MIPS CPU.
Any help would be amazing.
Best Regards,
Augusto Salazar
Software Engineer
Proscend Communications Inc.
--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2011-09-28 1:28 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-28 1:28 Vlan modifications Augusto Salazar
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox