linux/net
Ilia K ee5e81f000 add vif using local interface index instead of IP
When routing daemon wants to enable forwarding of multicast traffic it
performs something like:

       struct vifctl vc = {
               .vifc_vifi  = 1,
               .vifc_flags = 0,
               .vifc_threshold = 1,
               .vifc_rate_limit = 0,
               .vifc_lcl_addr = ip, /* <--- ip address of physical
interface, e.g. eth0 */
               .vifc_rmt_addr.s_addr = htonl(INADDR_ANY),
         };
       setsockopt(fd, IPPROTO_IP, MRT_ADD_VIF, &vc, sizeof(vc));

This leads (in the kernel) to calling  vif_add() function call which
search the (physical) device using assigned IP address:
       dev = ip_dev_find(net, vifc->vifc_lcl_addr.s_addr);

The current API (struct vifctl) does not allow to specify an
interface other way than using it's IP, and if there are more than a
single interface with specified IP only the first one will be found.

The attached patch (against 2.6.30.4) allows to specify an interface
by its index, instead of IP address:

       struct vifctl vc = {
               .vifc_vifi  = 1,
               .vifc_flags = VIFF_USE_IFINDEX,   /* NEW */
               .vifc_threshold = 1,
               .vifc_rate_limit = 0,
               .vifc_lcl_ifindex = if_nametoindex("eth0"),   /* NEW */
               .vifc_rmt_addr.s_addr = htonl(INADDR_ANY),
         };
       setsockopt(fd, IPPROTO_IP, MRT_ADD_VIF, &vc, sizeof(vc));

Signed-off-by: Ilia K. <mail4ilia@gmail.com>

=== modified file 'include/linux/mroute.h'
Signed-off-by: David S. Miller <davem@davemloft.net>
2009-10-07 00:48:41 -07:00
..
9p virtio: add virtio IDs file 2009-09-23 22:26:32 +09:30
802 net: remove COMPAT_NET_DEV_OPS 2009-05-25 01:53:53 -07:00
8021q net: fix vlan_get_size to include vlan_flags size 2009-09-26 20:16:07 -07:00
appletalk Have atalk_route_packet() return NET_RX_SUCCESS not NET_XMIT_SUCCESS 2009-09-14 17:02:47 -07:00
atm net: Make setsockopt() optlen be unsigned. 2009-09-30 16:12:20 -07:00
ax25 ax25: Fix possible oops in ax25_make_new 2009-09-30 16:44:12 -07:00
bluetooth net: Make setsockopt() optlen be unsigned. 2009-09-30 16:12:20 -07:00
bridge bridge: Fix double-free in br_add_if. 2009-09-28 12:54:25 -07:00
can net: Make setsockopt() optlen be unsigned. 2009-09-30 16:12:20 -07:00
core Merge branch 'master' of master.kernel.org:/pub/scm/linux/kernel/git/davem/net-2.6 2009-10-06 22:43:16 -07:00
dcb net: fix double skb free in dcbnl 2009-09-26 20:16:15 -07:00
dccp net: Make setsockopt() optlen be unsigned. 2009-09-30 16:12:20 -07:00
decnet net: Make setsockopt() optlen be unsigned. 2009-09-30 16:12:20 -07:00
dsa netdev: convert pseudo-devices to netdev_tx_t 2009-09-01 01:13:07 -07:00
econet Merge branch 'master' of master.kernel.org:/pub/scm/linux/kernel/git/davem/net-2.6 2009-08-12 17:44:53 -07:00
ethernet net: remove COMPAT_NET_DEV_OPS 2009-05-25 01:53:53 -07:00
ieee802154 net: Make setsockopt() optlen be unsigned. 2009-09-30 16:12:20 -07:00
ipv4 add vif using local interface index instead of IP 2009-10-07 00:48:41 -07:00
ipv6 tunnels: Optimize tx path 2009-10-05 00:21:57 -07:00
ipx net: Make setsockopt() optlen be unsigned. 2009-09-30 16:12:20 -07:00
irda net: Make setsockopt() optlen be unsigned. 2009-09-30 16:12:20 -07:00
iucv net: Make setsockopt() optlen be unsigned. 2009-09-30 16:12:20 -07:00
key net: file_operations should be const 2009-09-02 01:03:53 -07:00
lapb net: remove NET_RX_BAD and NET_RX_CN* defines 2009-07-05 19:15:35 -07:00
llc net: Make setsockopt() optlen be unsigned. 2009-09-30 16:12:20 -07:00
mac80211 cfg80211: assign device type in netdev notifier callback 2009-10-05 00:43:34 -07:00
netfilter net: Make setsockopt() optlen be unsigned. 2009-09-30 16:12:20 -07:00
netlabel Merge branch 'master' of master.kernel.org:/pub/scm/linux/kernel/git/davem/net-2.6 2009-07-30 19:22:43 -07:00
netlink net: Make setsockopt() optlen be unsigned. 2009-09-30 16:12:20 -07:00
netrom net: Make setsockopt() optlen be unsigned. 2009-09-30 16:12:20 -07:00
packet af_packet: add interframe drop cmsg (v6) 2009-10-05 00:21:55 -07:00
phonet Phonet: fix mutex imbalance 2009-09-30 16:41:34 -07:00
rds net: Make setsockopt() optlen be unsigned. 2009-09-30 16:12:20 -07:00
rfkill headers: remove sched.h from poll.h 2009-10-04 15:05:10 -07:00
rose net: Make setsockopt() optlen be unsigned. 2009-09-30 16:12:20 -07:00
rxrpc net: Make setsockopt() optlen be unsigned. 2009-09-30 16:12:20 -07:00
sched trivial: fix typo "to to" in multiple files 2009-09-21 15:14:55 +02:00
sctp net: Make setsockopt() optlen be unsigned. 2009-09-30 16:12:20 -07:00
sunrpc net: fix htmldocs sunrpc, clnt.c 2009-09-24 15:39:14 -07:00
tipc net: Make setsockopt() optlen be unsigned. 2009-09-30 16:12:20 -07:00
unix net: unix: fix sending fds in multiple buffers 2009-09-11 11:31:45 -07:00
wanrouter headers: smp_lock.h redux 2009-07-12 12:22:34 -07:00
wimax wimax: fix warning caused by not checking retval of rfkill_set_hw_state() 2009-06-11 11:12:48 -07:00
wireless cfg80211: assign device type in netdev notifier callback 2009-10-05 00:43:34 -07:00
x25 net: Make setsockopt() optlen be unsigned. 2009-09-30 16:12:20 -07:00
xfrm net: file_operations should be const 2009-09-02 01:03:53 -07:00
Kconfig net/compat/wext: send different messages to compat tasks 2009-07-15 08:53:39 -07:00
Makefile net: remove redundant sched/ in net/Makefile 2009-07-12 20:11:14 -07:00
TUNABLE
compat.c net: Make setsockopt() optlen be unsigned. 2009-09-30 16:12:20 -07:00
nonet.c
socket.c net: speedup sk_wake_async() 2009-10-06 17:28:29 -07:00
sysctl_net.c net: sysctl_net - use net_eq to compare nets 2009-03-16 16:23:30 +01:00