----- Original Message ----- > TS-32: FIX to perform multicast ICP communication > > Signed-off-by: Zhao Yongming <ming....@gmail.com> > > > Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo > Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/cf054cb3 > Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/cf054cb3 > Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/cf054cb3 > > Branch: refs/heads/master > Commit: cf054cb3ad57157a05f0e4d37b5065950f6bcbc6 > Parents: 05f7bfb > Author: Gota Adachi <a...@iij.ad.jp> > Authored: Tue Dec 24 15:15:55 2013 +0800 > Committer: Zhao Yongming <ming....@gmail.com> > Committed: Sun Dec 29 18:42:01 2013 +0800 > > ---------------------------------------------------------------------- > iocore/net/P_Connection.h | 1 + > iocore/net/UnixConnection.cc | 10 ++++++++-- > lib/ts/ink_inet.cc | 2 +- > proxy/ICP.cc | 1 + > 4 files changed, 11 insertions(+), 3 deletions(-) > ---------------------------------------------------------------------- > > > http://git-wip-us.apache.org/repos/asf/trafficserver/blob/cf054cb3/iocore/net/P_Connection.h > ---------------------------------------------------------------------- > diff --git a/iocore/net/P_Connection.h b/iocore/net/P_Connection.h > index 7abaa8e..e2fed75 100644 > --- a/iocore/net/P_Connection.h > +++ b/iocore/net/P_Connection.h > @@ -131,6 +131,7 @@ struct Connection > unsigned char mc_ttl = 1, bool mc_loopback = > DISABLE_MC_LOOPBACK, Continuation * c = NULL); > > int setup_mc_receive(sockaddr const* from, > + sockaddr const* my_addr, > bool non_blocking = NON_BLOCKING, Connection * > sendchan = NULL, Continuation * c = NULL); > > int close(); // 0 on success, -errno on failure > > http://git-wip-us.apache.org/repos/asf/trafficserver/blob/cf054cb3/iocore/net/UnixConnection.cc > ---------------------------------------------------------------------- > diff --git a/iocore/net/UnixConnection.cc b/iocore/net/UnixConnection.cc > index 98b931a..9a03c0e 100644 > --- a/iocore/net/UnixConnection.cc > +++ b/iocore/net/UnixConnection.cc > @@ -53,6 +53,7 @@ Connection::setup_mc_send( > ink_assert(fd == NO_FD); > int res = 0; > int enable_reuseaddr = 1; > + in_addr_t mc_if = ats_ip4_addr_cast(my_addr);
Is there a way to make this work with either IPv4 or IPv6? > > if ((res = socketManager.mc_socket(my_addr->sa_family, SOCK_DGRAM, 0, > non_blocking)) < 0) > goto Lerror; > @@ -82,6 +83,9 @@ Connection::setup_mc_send( > if ((res = safe_setsockopt(fd, IPPROTO_IP, IP_MULTICAST_TTL, (char *) > &mc_ttl, sizeof(mc_ttl)) < 0)) > goto Lerror; > > + // Set MultiCast Interface to specified value > + if ((res = safe_setsockopt(fd, IPPROTO_IP, IP_MULTICAST_IF, (char *) > &mc_if, sizeof(mc_if)) < 0)) > + goto Lerror; > > // Disable MultiCast loopback if requested > if (!mc_loopback) { > @@ -102,6 +106,7 @@ Lerror: > int > Connection::setup_mc_receive( > sockaddr const* mc_addr, > + sockaddr const* my_addr, > bool non_blocking, Connection * sendChan, Continuation * c > ) { > ink_assert(fd == NO_FD); > @@ -109,6 +114,7 @@ Connection::setup_mc_receive( > (void) c; > int res = 0; > int enable_reuseaddr = 1; > + IpAddr inaddr_any(INADDR_ANY); > > if ((res = socketManager.socket(mc_addr->sa_family, SOCK_DGRAM, 0)) < 0) > goto Lerror; > @@ -123,7 +129,7 @@ Connection::setup_mc_receive( > if ((res = safe_setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (char *) > &enable_reuseaddr, sizeof(enable_reuseaddr)) < 0)) > goto Lerror; > > - ats_ip_copy(&addr, mc_addr); > + addr.assign(inaddr_any, ats_ip_port_cast(mc_addr)); > > if ((res = socketManager.ink_bind(fd, &addr.sa, ats_ip_size(&addr.sa), > IPPROTO_TCP)) < 0) > goto Lerror; > @@ -136,7 +142,7 @@ Connection::setup_mc_receive( > struct ip_mreq mc_request; > // Add ourselves to the MultiCast group > mc_request.imr_multiaddr.s_addr = ats_ip4_addr_cast(mc_addr); > - mc_request.imr_interface.s_addr = INADDR_ANY; > + mc_request.imr_interface.s_addr = ats_ip4_addr_cast(my_addr); > > if ((res = safe_setsockopt(fd, IPPROTO_IP, IP_ADD_MEMBERSHIP, (char *) > &mc_request, sizeof(mc_request)) < 0)) > goto Lerror; > > http://git-wip-us.apache.org/repos/asf/trafficserver/blob/cf054cb3/lib/ts/ink_inet.cc > ---------------------------------------------------------------------- > diff --git a/lib/ts/ink_inet.cc b/lib/ts/ink_inet.cc > index 397e7da..3221ab2 100644 > --- a/lib/ts/ink_inet.cc > +++ b/lib/ts/ink_inet.cc > @@ -348,7 +348,7 @@ IpAddr::toString(char* dest, size_t len) const { > > bool > IpAddr::isMulticast() const { > - return (AF_INET == _family && 0xe == _addr._byte[0]) || > + return (AF_INET == _family && 0xe == (_addr._byte[0] >> 4)) || > (AF_INET6 == _family && IN6_IS_ADDR_MULTICAST(&_addr._ip6)) > ; > } > > http://git-wip-us.apache.org/repos/asf/trafficserver/blob/cf054cb3/proxy/ICP.cc > ---------------------------------------------------------------------- > diff --git a/proxy/ICP.cc b/proxy/ICP.cc > index 7e78925..8124a44 100644 > --- a/proxy/ICP.cc > +++ b/proxy/ICP.cc > @@ -2201,6 +2201,7 @@ ICPProcessor::SetupListenSockets() > } > > status = pMC->GetRecvChan()->setup_mc_receive(pMC->GetIP(), > + _LocalPeer->GetIP(), > NON_BLOCKING, > pMC->GetSendChan(), > _mcastCB_handler); > if (status) { > // coverity[uninit_use_in_call] > > -- Igor Galić Tel: +43 (0) 664 886 22 883 Mail: i.ga...@brainsware.org URL: http://brainsware.org/ GPG: 8716 7A9F 989B ABD5 100F 4008 F266 55D6 2998 1641