func SetupIfaceAddrs(veth netlink.Link, withMulticastRoute bool, cidrs []*net.IPNet) error {
	newAddresses, err := AddAddresses(veth, cidrs)
	if err != nil {
		return err
	}

	ifName := veth.Attrs().Name
	ipt, err := iptables.New()
	if err != nil {
		return err
	}

	// Add multicast ACCEPT rules for new subnets
	for _, ipnet := range newAddresses {
		acceptRule := []string{"-i", ifName, "-s", subnet(ipnet), "-d", "224.0.0.0/4", "-j", "ACCEPT"}
		exists, err := ipt.Exists("filter", "INPUT", acceptRule...)
		if err != nil {
			return err
		}
		if !exists {
			if err := ipt.Insert("filter", "INPUT", 1, acceptRule...); err != nil {
				return err
			}
		}
	}

	if err := netlink.LinkSetUp(veth); err != nil {
		return err
	}
	for _, ipnet := range newAddresses {
		// If we don't wait for a bit here, we see the arp fail to reach the bridge.
		time.Sleep(1 * time.Millisecond)
		arping.GratuitousArpOverIfaceByName(ipnet.IP, ifName)
	}
	if withMulticastRoute {
		/* Route multicast packets across the weave network.
		This must come last in 'attach'. If you change this, change weavewait to match.

		TODO: Add the MTU lock to prevent PMTU discovery for multicast
		destinations. Without that, the kernel sets the DF flag on
		multicast packets. Since RFC1122 prohibits sending of ICMP
		errors for packets with multicast destinations, that causes
		packets larger than the PMTU to be dropped silently.  */

		_, multicast, _ := net.ParseCIDR("224.0.0.0/4")
		if err := AddRoute(veth, netlink.SCOPE_LINK, multicast, nil); err != nil {
			return err
		}
	}
	return nil
}
// SetupIfaceAddrs is the implementation of the 'setup-iface-addrs' call above,
// running in another process in the container's netns
SetupIfaceAddrs is the implementation of the 'setup-iface-addrs' call above,
running in another process in the container's netns
// SetupIfaceAddrs is the implementation of the ' setup - iface - addrs ' call above // running in another process in the container ' s netns
func SetupIfaceAddrs(veth netlink.Link, withMulticastRoute bool, cidrs []*net.IPNet) error {
	newAddresses, err := AddAddresses(veth, cidrs)
	if err != nil {
		return err
	}
	ifName := veth.Attrs().Name
	ipt, err := iptables.New()
	if err != nil {
		return err
	}
	for _, ipnet := range newAddresses {
		acceptRule := []string{"-i", ifName, "-s", subnet(ipnet), "-d", "224.0.0.0/4", "-j", "ACCEPT"}
		exists, err := ipt.Exists("filter", "INPUT", acceptRule...)
		if err != nil {
			return err
		}
		if !exists {
			if err := ipt.Insert("filter", "INPUT", 1, acceptRule...); err != nil {
				return err
			}
		}
	}
	if err := netlink.LinkSetUp(veth); err != nil {
		return err
	}
	for _, ipnet := range newAddresses {
		time.Sleep(1 * time.Millisecond)
		arping.GratuitousArpOverIfaceByName(ipnet.IP, ifName)
	}
	if withMulticastRoute {
		_, multicast, _ := net.ParseCIDR("224.0.0.0/4")
		if err := AddRoute(veth, netlink.SCOPE_LINK, multicast, nil); err != nil {
			return err
		}
	}
	return nil
}
func SetupIfaceAddrs ( veth netlink . Link , withMulticastRoute bool , cidrs [ ] * net . IPNet ) error { newAddresses , err := AddAddresses ( veth , cidrs ) if err != nil { return err } ifName := veth . Attrs ( ) . Name ipt , err := iptables . New ( ) if err != nil { return err } for _ , ipnet := range newAddresses { acceptRule := [ ] string { " " , ifName , " " , subnet ( ipnet ) , " " , " " , " " , " " } exists , err := ipt . Exists ( " " , " " , acceptRule ... ) if err != nil { return err } if ! exists { if err := ipt . Insert ( " " , " " , 1 , acceptRule ... ) ; err != nil { return err } } } if err := netlink . LinkSetUp ( veth ) ; err != nil { return err } for _ , ipnet := range newAddresses { time . Sleep ( 1 * time . Millisecond ) arping . GratuitousArpOverIfaceByName ( ipnet . IP , ifName ) } if withMulticastRoute { _ , multicast , _ := net . ParseCIDR ( " " ) if err := AddRoute ( veth , netlink . SCOPE_LINK , multicast , nil ) ; err != nil { return err } } return nil }
SetupIfaceAddrs is the implementation of the 'setup-iface-addrs' call above,
running in another process in the container's netns
SetupIfaceAddrs is the implementation of the ' setup - iface - addrs ' call above running in another process in the container ' s netns
// Add multicast ACCEPT rules for new subnets // If we don't wait for a bit here, we see the arp fail to reach the bridge. /* Route multicast packets across the weave network.
		This must come last in 'attach'. If you change this, change weavewait to match.

		TODO: Add the MTU lock to prevent PMTU discovery for multicast
		destinations. Without that, the kernel sets the DF flag on
		multicast packets. Since RFC1122 prohibits sending of ICMP
		errors for packets with multicast destinations, that causes
		packets larger than the PMTU to be dropped silently.  */