diff mbox

add vif using local interface index (was Re: multicast routing and multiple interfaces with same IP)

Message ID 1b9338490909080021n6dcac8e8x40e7c4676df74e29@mail.gmail.com
State Changes Requested, archived
Delegated to: David Miller
Headers show

Commit Message

Ilia K. Sept. 8, 2009, 7:21 a.m. UTC
On Mon, Sep 7, 2009 at 7:25 PM, Octavian Purdila<opurdila@ixiacom.com> wrote:
> On Monday 07 September 2009 18:35:41 you wrote:
>> Hi,
>> I'm attaching a new patch. The changes:
>> mroute.h:
>> - consistent name for interface index: vifc_lcl_ifindex
>> - union of vifc_lcl_addr and vifc_lcl_ifindex since either one of them
>> can be used
>> ipmr.c:
>> - case VIFF_USE_IFINDEX and case 0 had almost the same code, so using
>> fall through and if to eliminate code duplication
>>
>
> Hi Ilia,
>
> Looks good to me, but there are a couple of code style issues reported by
> ./scripts/checkpatch.pl.
>
> Also, here:
>
>>+               } else {
>>+                       dev = ip_dev_find(net, vifc->vifc_lcl_addr.s_addr);
>>+               }
>
> Usually no braces are used for single line statements in if/else.

Hi,
I'm just  used to place braces either on both if/else parts or none,
but since you think this breaks linux code style, I've removed braces.
Another coding style issues reported by checkpatch.pl are fixed too.

Regards,
Ilia.

Comments

Octavian Purdila Sept. 8, 2009, 1:03 p.m. UTC | #1
On Tuesday 08 September 2009 10:21:18 you wrote:

> I'm just  used to place braces either on both if/else parts or none,
> but since you think this breaks linux code style, I've removed braces.
> Another coding style issues reported by checkpatch.pl are fixed too.
> 

One more thing :)

Can you please re-send the mail in "submission ready" format:
- subject line with [PATCH] and short summary of the change
- description of the change in the mail message 
- Signed-off-by line at the end of the description message

Here is an example: http://patchwork.ozlabs.org/patch/32684/

Thanks!
tavi
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

=== modified file 'include/linux/mroute.h'
--- old/include/linux/mroute.h	2009-08-10 11:17:32 +0000
+++ new/include/linux/mroute.h	2009-09-08 06:58:46 +0000
@@ -59,13 +59,18 @@ 
 	unsigned char vifc_flags;	/* VIFF_ flags */
 	unsigned char vifc_threshold;	/* ttl limit */
 	unsigned int vifc_rate_limit;	/* Rate limiter values (NI) */
-	struct in_addr vifc_lcl_addr;	/* Our address */
+	union {
+		struct in_addr vifc_lcl_addr;     /* Local interface address */
+		int            vifc_lcl_ifindex;  /* Local interface index   */
+	};
 	struct in_addr vifc_rmt_addr;	/* IPIP tunnel addr */
 };
 
-#define VIFF_TUNNEL	0x1	/* IPIP tunnel */
-#define VIFF_SRCRT	0x2	/* NI */
-#define VIFF_REGISTER	0x4	/* register vif	*/
+#define VIFF_TUNNEL		0x1	/* IPIP tunnel */
+#define VIFF_SRCRT		0x2	/* NI */
+#define VIFF_REGISTER		0x4	/* register vif	*/
+#define VIFF_USE_IFINDEX	0x8	/* use vifc_lcl_ifindex instead of
+					   vifc_lcl_addr to find an interface */
 
 /*
  *	Cache manipulation structures for mrouted and PIMd

=== modified file 'net/ipv4/ipmr.c'
--- old/net/ipv4/ipmr.c	2009-08-10 11:17:32 +0000
+++ new/net/ipv4/ipmr.c	2009-09-08 06:34:21 +0000
@@ -470,8 +470,18 @@ 
 			return err;
 		}
 		break;
+
+	case VIFF_USE_IFINDEX:
 	case 0:
-		dev = ip_dev_find(net, vifc->vifc_lcl_addr.s_addr);
+		if (vifc->vifc_flags == VIFF_USE_IFINDEX) {
+			dev = dev_get_by_index(net, vifc->vifc_lcl_ifindex);
+			if (dev && dev->ip_ptr == NULL) {
+				dev_put(dev);
+				return -EADDRNOTAVAIL;
+			}
+		} else
+			dev = ip_dev_find(net, vifc->vifc_lcl_addr.s_addr);
+
 		if (!dev)
 			return -EADDRNOTAVAIL;
 		err = dev_set_allmulti(dev, 1);