Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GratuitousArp not work, bridge can not receive arp package #463

Closed
hongli-my opened this issue Mar 19, 2020 · 2 comments · Fixed by #468
Closed

GratuitousArp not work, bridge can not receive arp package #463

hongli-my opened this issue Mar 19, 2020 · 2 comments · Fixed by #468

Comments

@hongli-my
Copy link

when create pod, GratuitousArp can only receive by veth on host, bridge can not get arp package by tcpdump
https://github.com/containernetworking/plugins/blob/master/plugins/main/bridge/bridge.go#L472

if add sleep here, will work well

		// Send a gratuitous arp
		for _, ipc := range result.IPs {
			if ipc.Version == "4" {
				time.Sleep(1 * time.Second)
				_ = arping.GratuitousArpOverIface(ipc.Address.IP, *contVeth)
			}
		}
@hongli-my
Copy link
Author

difference:
example 1: create veth pair in host ns , this work well
example 2: create veth pair in container ns, cbr0 can not receive arp package
example 1:

ip link add name veth1 mtu 1500 type veth peer name veth2 mtu 1500
ip netns add ns1
ip link set veth1 master cbr0
brctl hairpin cbr0 veth1 on
ip link set veth2 netns ns1
ip link set veth1 up
ip netns exec ns1 ip link set veth2 name eth0
ip netns exec ns1 ip -4 addr add xxxxxx/28 dev eth0
ip netns exec ns1 ip -4 link set eth0 up
ip netns exec ns1 ip route add default via  xxxxxxx
ip netns exec ns1 /tmp/test
ip netns del ns1

example 2:

ip netns add ns1
ip netns exec ns1 ip link add name veth1 mtu 1500 type veth peer name veth2 mtu 1500
ip netns exec ns1 ip link set veth2 name eth0
ip netns exec ns1 ip -4 addr add xxxxxx/28 dev eth0
ip netns exec ns1 ip -4 link set eth0 up
ip netns exec ns1 ip route add default via xxxxxxxx

ip netns exec ns1 ip link set dev veth1 netns 1
ip link set veth1 up
ip link set veth1 master cbr0
brctl hairpin cbr0 veth1 on
# sleep 1
ip netns exec ns1 /tmp/test

test.go

package main

import (
	"fmt"
	"net"

	"github.com/j-keck/arping"
)

func main() {

	xx, _ := net.InterfaceByName("eth0")
	err := arping.GratuitousArpOverIface(net.ParseIP("xxxxx"), *xx)
	fmt.Println(err)
}

@hongli-my
Copy link
Author

veth pair's state have delay time, br_add_if init port with p->state = BR_STATE_DISABLED and state change is async, It's better to check port status before send GratuitousArp.
image

@hongli-my hongli-my reopened this Mar 26, 2020
hongli-my added a commit to hongli-my/plugins that referenced this issue Mar 26, 2020
fix containernetworking#463
link host veth pair to bridge, the Initial state
of port is BR_STATE_DISABLED and change to
BR_STATE_FORWARDING async.
hongli-my added a commit to hongli-my/plugins that referenced this issue Mar 26, 2020
fix containernetworking#463
link host veth pair to bridge, the Initial state
of port is BR_STATE_DISABLED and change to
BR_STATE_FORWARDING async.

Signed-off-by: honglichang <honglichang@tencent.com>
hongli-my added a commit to hongli-my/plugins that referenced this issue Apr 6, 2020
fix containernetworking#463
link host veth pair to bridge, the Initial state
of port is BR_STATE_DISABLED and change to
BR_STATE_FORWARDING async.

Signed-off-by: honglichang <honglichang@tencent.com>
hongli-my added a commit to hongli-my/plugins that referenced this issue Apr 7, 2020
fix containernetworking#463
link host veth pair to bridge, the Initial state
of port is BR_STATE_DISABLED and change to
BR_STATE_FORWARDING async.

Signed-off-by: honglichang <honglichang@tencent.com>
hongli-my added a commit to hongli-my/plugins that referenced this issue Apr 8, 2020
fix containernetworking#463
link host veth pair to bridge, the Initial state
of port is BR_STATE_DISABLED and change to
BR_STATE_FORWARDING async.

Signed-off-by: honglichang <honglichang@tencent.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant