From: "Ilia K." <mail4ilia@gmail.com>
To: Octavian Purdila <opurdila@ixiacom.com>
Cc: David Miller <davem@davemloft.net>, netdev@vger.kernel.org
Subject: [PATCH] add vif using local interface index (was Re: multicast routing and multiple interfaces with same IP)
Date: Tue, 8 Sep 2009 10:21:18 +0300 [thread overview]
Message-ID: <1b9338490909080021n6dcac8e8x40e7c4676df74e29@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 1073 bytes --]
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.
[-- Attachment #2: vif_add.patch --]
[-- Type: text/x-diff, Size: 1634 bytes --]
=== 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);
next reply other threads:[~2009-09-08 7:21 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-09-08 7:21 Ilia K. [this message]
2009-09-08 13:03 ` [PATCH] add vif using local interface index (was Re: multicast routing and multiple interfaces with same IP) Octavian Purdila
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=1b9338490909080021n6dcac8e8x40e7c4676df74e29@mail.gmail.com \
--to=mail4ilia@gmail.com \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
--cc=opurdila@ixiacom.com \
/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;
as well as URLs for NNTP newsgroup(s).