public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Riccardo Scarsi <rscarsi@penguin.polito.it>
To: cap@di.fc.ul.pt
Cc: davem@redhat.com, linux-kernel@vger.kernel.org
Subject: [PATCH] multicast mroute
Date: Sun, 13 Jun 2004 21:42:40 +0200	[thread overview]
Message-ID: <20040613194240.GA32069@assi.polito.it> (raw)


This patch permits to add a multicast routing rule in the kernel that
specify an entire subnet for the multicast packets and not anly a
specific source address.



--- linux-2.4.24.vanilla/include/linux/mroute.h	2001-11-22 20:47:48.000000000 +0100
+++ linux-2.4.24/include/linux/mroute.h	2004-02-10 15:15:26.000000000 +0100
@@ -25,6 +25,7 @@
 #define MRT_VERSION	(MRT_BASE+6)	/* Get the kernel multicast version	*/
 #define MRT_ASSERT	(MRT_BASE+7)	/* Activate PIM assert mode		*/
 #define MRT_PIM		(MRT_BASE+8)	/* enable PIM code	*/
+#define MRT_ADD_MFC_NM	(MRT_BASE+9)	/* Add a multicast forwarding entry	*/
 
 #define SIOCGETVIFCNT	SIOCPROTOPRIVATE	/* IP protocol privates */
 #define SIOCGETSGCNT	(SIOCPROTOPRIVATE+1)
@@ -78,6 +79,8 @@
 	unsigned int mfcc_byte_cnt;
 	unsigned int mfcc_wrong_if;
 	int	     mfcc_expire;
+	struct in_addr mfcc_origin_netmask;	/* Netmask of the origin 
+						of mcast	*/
 };
 
 /* 
@@ -169,6 +172,7 @@
 			unsigned char ttls[MAXVIFS];	/* TTL thresholds		*/
 		} res;
 	} mfc_un;
+	__u32 mfc_origin_netmask;			/* Netmask of source of packet 		*/
 };
 
 #define MFC_STATIC		1
--- linux-2.4.24.vanilla/net/ipv4/ipmr.c	2003-11-28 19:26:21.000000000 +0100
+++ linux-2.4.24/net/ipv4/ipmr.c	2004-02-10 15:03:47.000000000 +0100
@@ -450,6 +450,18 @@
 	return 0;
 }
 
+static struct mfc_cache *ipmr_cache_find_netmask(__u32 origin, __u32 mcastgrp)
+{
+	int line=MFC_HASH(mcastgrp,origin);
+	struct mfc_cache *c;
+
+	for (c=mfc_cache_array[line]; c; c = c->next) {
+		if ((c->mfc_origin & c->mfc_origin_netmask)==(origin & c->mfc_origin_netmask) && c->mfc_mcastgrp==mcastgrp)
+			break;
+	}
+	return c;
+}
+
 static struct mfc_cache *ipmr_cache_find(__u32 origin, __u32 mcastgrp)
 {
 	int line=MFC_HASH(mcastgrp,origin);
@@ -901,6 +913,7 @@
 		 *	Manipulate the forwarding caches. These live
 		 *	in a sort of kernel/user symbiosis.
 		 */
+		case MRT_ADD_MFC_NM:
 		case MRT_ADD_MFC:
 		case MRT_DEL_MFC:
 			if(optlen!=sizeof(mfc))
@@ -908,6 +921,8 @@
 			if (copy_from_user(&mfc,optval, sizeof(mfc)))
 				return -EFAULT;
 			rtnl_lock();
+			if (optname==MRT_ADD_MFC)
+				mfc.mfcc_origin_netmask.s_addr = 0xffffffff;
 			if (optname==MRT_DEL_MFC)
 				ret = ipmr_mfc_delete(&mfc);
 			else
@@ -1336,7 +1351,7 @@
 	}
 
 	read_lock(&mrt_lock);
-	cache = ipmr_cache_find(skb->nh.iph->saddr, skb->nh.iph->daddr);
+	cache = ipmr_cache_find_netmask(skb->nh.iph->saddr, skb->nh.iph->daddr);
 
 	/*
 	 *	No usable cache entry


             reply	other threads:[~2004-06-13 19:43 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-06-13 19:42 Riccardo Scarsi [this message]
2004-06-15  1:01 ` [PATCH] multicast mroute David S. Miller

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=20040613194240.GA32069@assi.polito.it \
    --to=rscarsi@penguin.polito.it \
    --cc=cap@di.fc.ul.pt \
    --cc=davem@redhat.com \
    --cc=linux-kernel@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