mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-24 12:44:11 +08:00
ipv4: Allow sending multicast packets on specific i/f using VRF socket
It is useful to be able to use the same socket for listening in a specific VRF, as for sending multicast packets out of a specific interface. However, the bound device on the socket currently takes precedence and results in the packets not being sent. Relax the condition on overriding the output interface to use for sending packets out of UDP, raw and ping sockets to allow multicast packets to be sent using the specified multicast interface. Signed-off-by: Robert Shearman <rshearma@vyatta.att-mail.com> Signed-off-by: Mike Manning <mmanning@vyatta.att-mail.com> Reviewed-by: David Ahern <dsahern@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
6919622af3
commit
854da99173
@ -42,7 +42,7 @@ int __ip4_datagram_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len
|
||||
oif = sk->sk_bound_dev_if;
|
||||
saddr = inet->inet_saddr;
|
||||
if (ipv4_is_multicast(usin->sin_addr.s_addr)) {
|
||||
if (!oif)
|
||||
if (!oif || netif_index_is_l3_master(sock_net(sk), oif))
|
||||
oif = inet->mc_index;
|
||||
if (!saddr)
|
||||
saddr = inet->mc_addr;
|
||||
|
@ -779,7 +779,7 @@ static int ping_v4_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
|
||||
}
|
||||
|
||||
if (ipv4_is_multicast(daddr)) {
|
||||
if (!ipc.oif)
|
||||
if (!ipc.oif || netif_index_is_l3_master(sock_net(sk), ipc.oif))
|
||||
ipc.oif = inet->mc_index;
|
||||
if (!saddr)
|
||||
saddr = inet->mc_addr;
|
||||
|
@ -608,7 +608,7 @@ static int raw_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
|
||||
tos |= RTO_ONLINK;
|
||||
|
||||
if (ipv4_is_multicast(daddr)) {
|
||||
if (!ipc.oif)
|
||||
if (!ipc.oif || netif_index_is_l3_master(sock_net(sk), ipc.oif))
|
||||
ipc.oif = inet->mc_index;
|
||||
if (!saddr)
|
||||
saddr = inet->mc_addr;
|
||||
|
@ -1042,7 +1042,7 @@ int udp_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
|
||||
}
|
||||
|
||||
if (ipv4_is_multicast(daddr)) {
|
||||
if (!ipc.oif)
|
||||
if (!ipc.oif || netif_index_is_l3_master(sock_net(sk), ipc.oif))
|
||||
ipc.oif = inet->mc_index;
|
||||
if (!saddr)
|
||||
saddr = inet->mc_addr;
|
||||
|
Loading…
Reference in New Issue
Block a user