linux/net/ipv4
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
..
netfilter
af_inet.c net: Use sk_mark for routing lookup in more places 2009-10-01 15:16:49 -07:00
ah4.c net: constify struct net_protocol 2009-09-14 17:03:01 -07:00
arp.c
cipso_ipv4.c
datagram.c
devinet.c sysctl: remove "struct file *" argument of ->proc_handler 2009-09-24 07:21:04 -07:00
esp4.c net: constify struct net_protocol 2009-09-14 17:03:01 -07:00
fib_frontend.c ipv4: fib table algorithm performance improvement 2009-10-05 00:21:56 -07:00
fib_hash.c ipv4: fib table algorithm performance improvement 2009-10-05 00:21:56 -07:00
fib_lookup.h
fib_rules.c ipv4: fib table algorithm performance improvement 2009-10-05 00:21:56 -07:00
fib_semantics.c
fib_trie.c ipv4: fib table algorithm performance improvement 2009-10-05 00:21:56 -07:00
icmp.c icmp: No need to call sk_write_space() 2009-10-05 00:21:54 -07:00
igmp.c bonding: remap muticast addresses without using dev_close() and dev_open() 2009-09-15 02:37:40 -07:00
inet_connection_sock.c net: Make setsockopt() optlen be unsigned. 2009-09-30 16:12:20 -07:00
inet_diag.c
inet_fragment.c
inet_hashtables.c
inet_lro.c
inet_timewait_sock.c
inetpeer.c
ip_forward.c
ip_fragment.c
ip_gre.c tunnels: Optimize tx path 2009-10-05 00:21:57 -07:00
ip_input.c net: constify struct net_protocol 2009-09-14 17:03:01 -07:00
ip_options.c
ip_output.c net: Use sk_mark for routing lookup in more places 2009-10-01 15:16:49 -07:00
ip_sockglue.c net: Make setsockopt() optlen be unsigned. 2009-09-30 16:12:20 -07:00
ipcomp.c net: constify struct net_protocol 2009-09-14 17:03:01 -07:00
ipconfig.c
ipip.c tunnels: Optimize tx path 2009-10-05 00:21:57 -07:00
ipmr.c add vif using local interface index instead of IP 2009-10-07 00:48:41 -07:00
Kconfig
Makefile
netfilter.c
proc.c
protocol.c net: constify struct net_protocol 2009-09-14 17:03:01 -07:00
raw.c net: Make setsockopt() optlen be unsigned. 2009-09-30 16:12:20 -07:00
route.c sysctl: remove "struct file *" argument of ->proc_handler 2009-09-24 07:21:04 -07:00
syncookies.c
sysctl_net_ipv4.c sysctl: remove "struct file *" argument of ->proc_handler 2009-09-24 07:21:04 -07:00
tcp.c net: splice() from tcp to pipe should take into account O_NONBLOCK 2009-10-02 09:46:05 -07:00
tcp_bic.c
tcp_cong.c
tcp_cubic.c
tcp_diag.c
tcp_highspeed.c
tcp_htcp.c
tcp_hybla.c
tcp_illinois.c
tcp_input.c tcp: fix ssthresh u16 leftover 2009-09-15 01:30:10 -07:00
tcp_ipv4.c tcp: fix ssthresh u16 leftover 2009-09-15 01:30:10 -07:00
tcp_lp.c
tcp_minisocks.c tcp: fix CONFIG_TCP_MD5SIG + CONFIG_PREEMPT timer BUG() 2009-09-15 23:49:21 -07:00
tcp_output.c IPv4 TCP fails to send window scale option when window scale is zero 2009-10-01 15:14:51 -07:00
tcp_probe.c
tcp_scalable.c
tcp_timer.c
tcp_vegas.c
tcp_vegas.h
tcp_veno.c
tcp_westwood.c
tcp_yeah.c
tunnel4.c net: constify struct net_protocol 2009-09-14 17:03:01 -07:00
udp.c net: Use sk_mark for routing lookup in more places 2009-10-01 15:16:49 -07:00
udp_impl.h net: Make setsockopt() optlen be unsigned. 2009-09-30 16:12:20 -07:00
udplite.c net: constify struct net_protocol 2009-09-14 17:03:01 -07:00
xfrm4_input.c
xfrm4_mode_beet.c
xfrm4_mode_transport.c
xfrm4_mode_tunnel.c
xfrm4_output.c
xfrm4_policy.c
xfrm4_state.c
xfrm4_tunnel.c