From: "Augusto Salazar" <augusto@proscend.com>
To: netfilter@vger.kernel.org
Subject: Vlan modifications
Date: Wed, 28 Sep 2011 09:28:30 +0800 [thread overview]
Message-ID: <00b301cc7d7d$ee60d850$cb2288f0$@com> (raw)
In-Reply-To:
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.
reply other threads:[~2011-09-28 1:28 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='00b301cc7d7d$ee60d850$cb2288f0$@com' \
--to=augusto@proscend.com \
--cc=netfilter@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox