Skip to contentSkip to conversation

don't try to track broadcasts or multicasts (4/4)

PATCH In review Martin Josefsson 3 participants 5 messages Jun 6, 2002 – Jun 9, 2002

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 don't try to track broadcasts or multicasts (4/4)

There exists code to disable tracking of broadcasts but it's insice a #if 0 / #endif in ip_conntrack_core.c and looks like some old debugging code as it has printk's and stuff.

this patch removes that chunk and replaces it with a check so if the packet is a broadcast or multicast we just return NF_ACCEPT since there's not much point in us trying to track it.

Signature · 4 lines
/Martin

Never argue with an idiot. They drag you down to their level, then beat
you with experience.
net/ipv4/netfilter/ip_conntrack_core.c renamed from net/ipv4/netfilter/ip_conntrack_core.c.orig +2 -13
@@ -737,20 +737,9 @@
 	/* FIXME: Do this right please. --RR */
 	(*pskb)->nfcache |= NFC_UNKNOWN;
 
-/* Doesn't cover locally-generated broadcast, so not worth it. */
-#if 0
-	/* Ignore broadcast: no `connection'. */
-	if ((*pskb)->pkt_type == PACKET_BROADCAST) {
-		printk("Broadcast packet!\n");
+	/* Don't try to track broadcasts or multicasts. */
+	if ((*pskb)->pkt_type == PACKET_BROADCAST || (*pskb)->pkt_type == PACKET_MULTICAST)
 		return NF_ACCEPT;
-	} else if (((*pskb)->nh.iph->daddr & htonl(0x000000FF)) 
-		   == htonl(0x000000FF)) {
-		printk("Should bcast: %u.%u.%u.%u->%u.%u.%u.%u (sk=%p, ptype=%u)\n",
-		       NIPQUAD((*pskb)->nh.iph->saddr),
-		       NIPQUAD((*pskb)->nh.iph->daddr),
-		       (*pskb)->sk, (*pskb)->pkt_type);
-	}
-#endif
 
 	/* Previously seen (loopback)?  Ignore.  Do this before
            fragment check. */
#1 lore raw
Quoted 7 lines · Martin Josefsson

There exists code to disable tracking of broadcasts but it's insice a #if 0 / #endif in ip_conntrack_core.c and looks like some old debugging code as it has printk's and stuff.

this patch removes that chunk and replaces it with a check so if the packet is a broadcast or multicast we just return NF_ACCEPT since there's not much point in us trying to track it.

hm. I would generally agree with you, but there is one issue which needs to be looked into before considering this patch:

What happens if some client sends an ip-unicast diagram as link layer broadcast? How does the linux stack react to this?

If the packet is processed/routed the same way like any other ip-unicast link-layer unicast packet, we still need to do tracking of broadcast packets.

Could you try to look into that and keep us posted?

Thanks.

Quoted 1 line

/Martin

Signature · 5 lines
Live long and prosper
- Harald Welte / [email protected]               http://www.gnumonks.org/
============================================================================
GCS/E/IT d- s-: a-- C+++ UL++++$ P+++ L++++$ E--- W- N++ o? K- w--- O- M- 
V-- PS+ PE-- Y+ PGP++ t++ 5-- !X !R tv-- b+++ DI? !D G+ e* h+ r% y+(*)
#2 lore raw
Quoted 11 lines · Harald Welte

hm. I would generally agree with you, but there is one issue which needs to be looked into before considering this patch:

What happens if some client sends an ip-unicast diagram as link layer broadcast? How does the linux stack react to this?

If the packet is processed/routed the same way like any other ip-unicast link-layer unicast packet, we still need to do tracking of broadcast packets.

Could you try to look into that and keep us posted?

Hmm why didn't I think about that?

I've done some simple testing and the results are:

TCP:
send SYN to ll broadcast: ignored
send SYN,ACK to ll broadcast: ignored

UDP:
packet sent to ll broadcast: accepted

ICMP:
echo-request sent to ll broadcast: accepted
echo-reply sent to ll broadcast: accepted
port unreachable sent to ll broadcast: accepted

I havn't done any tests with multicast ll addresses.

Seeing these results there's not much need for a patch of this kind. TCP ll broadcasts are extremely rare. almost all ll broadcasts here are UDP.

It was a nice thought but doesn't work in the real world.

Signature · 4 lines
/Martin

Never argue with an idiot. They drag you down to their level, then beat
you with experience.
#3 lore raw
Quoted 1 line · Martin Josefsson

Hmm why didn't I think about that?

it just came to my mind after reading your mail..

Quoted 1 line

I've done some simple testing and the results are:

the results are actually quite interesting - but maybe there's a particular reason for TCP behaving different than other protocols...

Quoted 1 line

It was a nice thought but doesn't work in the real world.

yup, it would have been a nice optimization...

Quoted 1 line

/Martin

Signature · 5 lines
Live long and prosper
- Harald Welte / [email protected]               http://www.gnumonks.org/
============================================================================
GCS/E/IT d- s-: a-- C+++ UL++++$ P+++ L++++$ E--- W- N++ o? K- w--- O- M- 
V-- PS+ PE-- Y+ PGP++ t++ 5-- !X !R tv-- b+++ DI? !D G+ e* h+ r% y+(*)
#4 lore raw
Quoted 3 lines · Harald Welte

the results are actually quite interesting - but maybe there's a particular reason for TCP behaving different than other protocols...

Broadcast or multicast does not apply to TCP. It does in the other protocols (ICMP / UDP). A broadcast or multicast packet received by TCP is with no doubt a martian as there is no aspect of TCP that can be safely used on other than unicast links.

Linux ICMP seems to have some provision to filter out broadcasts when they do not make sense, but it could do better I think..

But I think this aspect of the Linux IP stack can be ignored local traffic. If you receive a broadcast frame addressed to your unicast IP address then the processing should not be much different from receiving a broadcast frame addressed to your broadcast address. The likelyhood that there is TCP/IP implementations sending you broadcast link frames when unicast was intended is very low.

But the reverse cannot be assumed. There is special applications of TCP/IP where multicast is used as local transport. This can be seen in some odd active-active load balancing products where all servers must see all packets, so a Linux server/router can be required to receive unicast IP frames from a multicast link source address or to sent unicast IP to a multicast link address..

If this is considered in a bridge environment using the bridge-netfilter integration then obviously no optimization based on unicast/multicast link transport can be done on forwarded packets..

Regards
Henrik