aboutsummaryrefslogtreecommitdiffstats
path: root/net/tipc
diff options
context:
space:
mode:
Diffstat (limited to 'net/tipc')
-rw-r--r--net/tipc/udp_media.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/net/tipc/udp_media.c b/net/tipc/udp_media.c
index 9783101bc4a9..10dc59ce9c82 100644
--- a/net/tipc/udp_media.c
+++ b/net/tipc/udp_media.c
@@ -650,6 +650,7 @@ static int tipc_udp_enable(struct net *net, struct tipc_bearer *b,
650 struct udp_tunnel_sock_cfg tuncfg = {NULL}; 650 struct udp_tunnel_sock_cfg tuncfg = {NULL};
651 struct nlattr *opts[TIPC_NLA_UDP_MAX + 1]; 651 struct nlattr *opts[TIPC_NLA_UDP_MAX + 1];
652 u8 node_id[NODE_ID_LEN] = {0,}; 652 u8 node_id[NODE_ID_LEN] = {0,};
653 int rmcast = 0;
653 654
654 ub = kzalloc(sizeof(*ub), GFP_ATOMIC); 655 ub = kzalloc(sizeof(*ub), GFP_ATOMIC);
655 if (!ub) 656 if (!ub)
@@ -680,6 +681,9 @@ static int tipc_udp_enable(struct net *net, struct tipc_bearer *b,
680 if (err) 681 if (err)
681 goto err; 682 goto err;
682 683
684 /* Checking remote ip address */
685 rmcast = tipc_udp_is_mcast_addr(&remote);
686
683 /* Autoconfigure own node identity if needed */ 687 /* Autoconfigure own node identity if needed */
684 if (!tipc_own_id(net)) { 688 if (!tipc_own_id(net)) {
685 memcpy(node_id, local.ipv6.in6_u.u6_addr8, 16); 689 memcpy(node_id, local.ipv6.in6_u.u6_addr8, 16);
@@ -705,7 +709,12 @@ static int tipc_udp_enable(struct net *net, struct tipc_bearer *b,
705 goto err; 709 goto err;
706 } 710 }
707 udp_conf.family = AF_INET; 711 udp_conf.family = AF_INET;
708 udp_conf.local_ip.s_addr = htonl(INADDR_ANY); 712
713 /* Switch to use ANY to receive packets from group */
714 if (rmcast)
715 udp_conf.local_ip.s_addr = htonl(INADDR_ANY);
716 else
717 udp_conf.local_ip.s_addr = local.ipv4.s_addr;
709 udp_conf.use_udp_checksums = false; 718 udp_conf.use_udp_checksums = false;
710 ub->ifindex = dev->ifindex; 719 ub->ifindex = dev->ifindex;
711 if (tipc_mtu_bad(dev, sizeof(struct iphdr) + 720 if (tipc_mtu_bad(dev, sizeof(struct iphdr) +
@@ -719,7 +728,10 @@ static int tipc_udp_enable(struct net *net, struct tipc_bearer *b,
719 udp_conf.family = AF_INET6; 728 udp_conf.family = AF_INET6;
720 udp_conf.use_udp6_tx_checksums = true; 729 udp_conf.use_udp6_tx_checksums = true;
721 udp_conf.use_udp6_rx_checksums = true; 730 udp_conf.use_udp6_rx_checksums = true;
722 udp_conf.local_ip6 = in6addr_any; 731 if (rmcast)
732 udp_conf.local_ip6 = in6addr_any;
733 else
734 udp_conf.local_ip6 = local.ipv6;
723 b->mtu = 1280; 735 b->mtu = 1280;
724#endif 736#endif
725 } else { 737 } else {
@@ -741,7 +753,7 @@ static int tipc_udp_enable(struct net *net, struct tipc_bearer *b,
741 * is used if it's a multicast address. 753 * is used if it's a multicast address.
742 */ 754 */
743 memcpy(&b->bcast_addr.value, &remote, sizeof(remote)); 755 memcpy(&b->bcast_addr.value, &remote, sizeof(remote));
744 if (tipc_udp_is_mcast_addr(&remote)) 756 if (rmcast)
745 err = enable_mcast(ub, &remote); 757 err = enable_mcast(ub, &remote);
746 else 758 else
747 err = tipc_udp_rcast_add(b, &remote); 759 err = tipc_udp_rcast_add(b, &remote);