Uploaded image for project: 'JGroups'
  1. JGroups
  2. JGRP-1316

MPING doesn't always bind to correct interface address

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Minor
    • 3.0
    • 2.12.1
    • None
    • Hide

      private void bindToInterfaces(List<NetworkInterface> interfaces, MulticastSocket s, InetAddress mcast_addr) throws IOException {
      SocketAddress tmp_mcast_addr=new InetSocketAddress(mcast_addr, mcast_port);
      for(Iterator it=interfaces.iterator(); it.hasNext() {
      NetworkInterface i=(NetworkInterface)it.next();
      for(Enumeration en2=i.getInetAddresses(); en2.hasMoreElements() {
      InetAddress addr=(InetAddress)en2.nextElement();
      if ((Util.getIpStackType() == StackType.IPv4 && addr instanceof Inet4Address) || (Util.getIpStackType() == StackType.IPv6 && addr instanceof Inet6Address))

      { s.joinGroup(tmp_mcast_addr, i); if(log.isTraceEnabled()) log.trace("joined " + tmp_mcast_addr + " on " + i.getName() + " (" + addr + ")"); break; }

      }
      }
      }

      Show
      private void bindToInterfaces(List<NetworkInterface> interfaces, MulticastSocket s, InetAddress mcast_addr) throws IOException { SocketAddress tmp_mcast_addr=new InetSocketAddress(mcast_addr, mcast_port); for(Iterator it=interfaces.iterator(); it.hasNext() { NetworkInterface i=(NetworkInterface)it.next(); for(Enumeration en2=i.getInetAddresses(); en2.hasMoreElements() { InetAddress addr=(InetAddress)en2.nextElement(); if ((Util.getIpStackType() == StackType.IPv4 && addr instanceof Inet4Address) || (Util.getIpStackType() == StackType.IPv6 && addr instanceof Inet6Address)) { s.joinGroup(tmp_mcast_addr, i); if(log.isTraceEnabled()) log.trace("joined " + tmp_mcast_addr + " on " + i.getName() + " (" + addr + ")"); break; } } } }

    Description

      MPING's bindToInterfaces method doesn't take the stack type into consideration. It iterates through all interfaces and addresses but binds to the first address on each interface – which may not be the correct one based on Util.getIpStackType().

      See Workaround Description for workaround solution that worked for me.

      Attachments

        Activity

          People

            rhn-engineering-bban Bela Ban
            whizzosoftware Daniel Noguerol (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: