Skip to contentSkip to conversation

Question about mac addresses in IP hook.,

DISCUSSION hMax Roth 2 participants 2 messages Sep 14, 2002 – Sep 16, 2002 netfilter

lore
Share & tools
lore

hMax Roth

author
#0 lore raw

Thanks for the response.
On the NF_IP_PRE_ROUTING I can get the mac header without a problem (what a relief! Thanks for the help, it really helped a lot) Basically, it's always 14 bytes before the data pointer or on the .mac union. However, the outbound hook, the mac address pointer is still randomly NULL and pointing to strange data! I can't understand it. The code looks something like this

<in NF_IP_LOCAL_OUToutbound hook>

if ((*pkb)->mac.ethernet)

	PrintPacket((*pskb)->mac.raw, 14);
I	<or>
	PrintData((*pskb)->mac.ehernet->h_source, 6)
else
	Printk(�Ethernet header is NULL�);

(h_source points to the source array in the Ethernet header struct. I�m not sure what the exact name is)
If I sniff the connect, I can see the packets coming out correctly, but my hook keeps seeing NULL?
I wonder if it�s a bug. I know that the Ethernet driver is supposed to populate the Ethernet header pointer on the inbound packets, who sets them on the outbound? Any ideas?

Quoted 13 lines

From: "Eble, Dan" <[email protected]>
To: 'hMax Roth' <[email protected]>
Subject: RE: Question about mac addresses in IP hook.,
Date: Fri, 13 Sep 2002 09:08:32 -0400

Have you examined the source for the kernel MAC matcher module in net/ipv4/netfilter/ipt_mac.c? What device drivers are you using for your network interfaces? Could there be bug in one of them?

If you find an answer to this problem, I am interested in hearing it as well. I haven't started testing MAC filters in my system yet, but when I do, I'll let you know if I run into any problems like this.

Quoted 48 lines

--

Dan Eble <[email protected]>           _____  .
Applied Innovation Inc.             |  _  |/|
Dublin, OH  43017-3271              | |_| | |
614-923-1185 or 800-247-9482 x2051  |__/|_|_|
Quoted 42 lines

-----Original Message-----
From: hMax Roth [mailto:[email protected]]
Sent: Thursday, September 12, 2002 11:04 PM
To: [email protected]
Subject: Question about mac addresses in IP hook.,

Hello,
I'm having a tough time working on a tunnel type protocol
for Linux. I'm
using netfilter and have registered my call back for the first imbound hook.
I'm able to see the IP headers + UDP + etc, but I cannot get at the mac
address. I've tried reading the (*skb)->mac.ethernet but the pointer comes
out NULL sometimes!? I thought that since because I'm registering on the IP
hook, I'm gaurenteed to have an IP packet (with mac address field filled
in?). I also tried printing out the data between (*skb)->head to (*skb)->data but I sometimes get funny data. If I send a stream of UDP
packets, the first one usually has a messed up MAC field while all the other
ones are fine (sometimes it's totally random too!). Am I gaurenteed to have
a valid MAC address on the NF_IP_PRE_ROUTING hook? And if so, where is it?
Sorry, if I got the wrong mailing list. I wasn't sure which one to ask on.
Regards, Max.

P.s. I'm unable to subscribe to the list at the moment so could you please
email me the solution. Thanks guys.

_________________________________________________________________
MSN Photos is the easiest way to share and print your photos:
http://photos.msn.com/support/worldwide.aspx

_________________________________________________________________
MSN Photos is the easiest way to share and print your photos: http://photos.msn.com/support/worldwide.aspx

#1 lore raw
Quoted 8 lines · hMax Roth

Thanks for the response.
On the NF_IP_PRE_ROUTING I can get the mac header without a problem (what a relief! Thanks for the help, it really helped a lot) Basically, it's always 14 bytes before the data pointer or on the .mac union. However, the outbound hook, the mac address pointer is still randomly NULL and pointing to strange data! I can't understand it. The code looks something like this

<in NF_IP_LOCAL_OUToutbound hook>

Stop right there. For outbound packets, all the way through to POST_ROUTING, there is NO WAY the outbound ethernet header could already be in place for all cases. Think about sending to a station which is not yet in the local ARP cache. Before the kernel can be sure of the destination MAC address, it keeps back the original outgoing packet, makes an ARP broadcast, and only when it hears back, can it send on the packet on its journey.

If what you naively expect, must be implemented, then all filtering action has to be postponed to the moment where the outgoing header is completely determined - doing so would need an almost complete rearrangement of the output path of iptables (and probably much meddling with the network stack itself). Furthermore, it would open the possibility for to-be-blocked traffic to neccessiate traffic, namely the ARP request/reply.

Can you see why things are the way they are, now?

(There is a small chance, that I'm wrong for the POST_ROUTING hook. Somebody please correct me if that hook guarantees L2 header availability. I haven't looked closely at the code, so far.)

best regards
Patrick