netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC] net: ipv4: drop unicast encapsulated in L2 multicast
@ 2014-08-21 17:22 Johannes Berg
  2014-08-21 17:32 ` Johannes Berg
                   ` (2 more replies)
  0 siblings, 3 replies; 19+ messages in thread
From: Johannes Berg @ 2014-08-21 17:22 UTC (permalink / raw)
  To: linux-wireless, netdev; +Cc: Johannes Berg

From: Johannes Berg <johannes.berg@intel.com>

RFC 1122 says that unicast packets encapsulated in broadcast
link-layer packets should be dropped. Implement that, but also
extend it to link-layer multicast packets.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
---
 net/ipv4/route.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index eaa4b000c7b4..c374fcc73ee0 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -1710,6 +1710,23 @@ static int ip_route_input_slow(struct sk_buff *skb, __be32 daddr, __be32 saddr,
 		goto no_route;
 	}
 
+	/* RFC 1122 3.3.6:
+	 *
+	 *   When a host sends a datagram to a link-layer broadcast address,
+	 *   the IP destination address MUST be a legal IP broadcast or IP
+	 *   multicast address.
+	 *
+	 *   A host SHOULD silently discard a datagram that is received via
+	 *   a link-layer broadcast (see Section 2.4) but does not specify
+	 *   an IP multicast or broadcast destination address.
+	 *
+	 * We also do this for link-layer multicast.
+	 */
+	if ((skb->pkt_type == PACKET_BROADCAST ||
+	     skb->pkt_type == PACKET_MULTICAST) &&
+	    res.type != RTN_BROADCAST)
+		goto e_inval;
+
 	if (res.type == RTN_BROADCAST)
 		goto brd_input;
 
-- 
2.0.0

^ permalink raw reply related	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2014-11-20 21:31 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-08-21 17:22 [RFC] net: ipv4: drop unicast encapsulated in L2 multicast Johannes Berg
2014-08-21 17:32 ` Johannes Berg
     [not found]   ` <1408642331.4388.2.camel-8Nb76shvtaUJvtFkdXX2HixXY32XiHfO@public.gmane.org>
2014-08-27  7:38     ` Hannes Frederic Sowa
2014-08-27  9:05       ` Johannes Berg
2014-08-27  9:53         ` Hannes Frederic Sowa
2014-09-02  9:36           ` Johannes Berg
2014-09-03  1:59             ` YOSHIFUJI Hideaki
     [not found]               ` <540675F2.1030308-GmhWrQMWH5w7YuNMryXyOw@public.gmane.org>
2014-09-02 22:03                 ` David Miller
     [not found]                   ` <20140902.150326.1420682815750767731.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
2014-09-03 12:01                     ` Hannes Frederic Sowa
2014-08-21 19:51 ` Julian Anastasov
     [not found]   ` <alpine.LFD.2.11.1408212119510.1896-c1lBKlETG9EWAawoAK+ZAw@public.gmane.org>
2014-08-22 17:54     ` David Miller
2014-08-27  9:13       ` Johannes Berg
     [not found]         ` <1409130792.2505.5.camel-8Nb76shvtaUJvtFkdXX2HixXY32XiHfO@public.gmane.org>
2014-08-27 10:23           ` Julian Anastasov
     [not found]             ` <alpine.LFD.2.11.1408271255230.2348-c1lBKlETG9EWAawoAK+ZAw@public.gmane.org>
2014-08-27 11:29               ` Johannes Berg
2014-08-27 14:31                 ` Julian Anastasov
2014-09-02  9:33                   ` Johannes Berg
     [not found]       ` <20140822.105405.1982870131653082781.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
2014-11-20 21:31         ` Johannes Berg
     [not found] ` <1408641747-22199-1-git-send-email-johannes-cdvu00un1VgdHxzADdlk8Q@public.gmane.org>
2014-09-02 21:16   ` Stephen Hemminger
2014-09-03  9:40     ` Johannes Berg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).