From dd0808ae5450160c021d911c62d525bd1cf44c9e Mon Sep 17 00:00:00 2001 From: Zha Bin Date: Tue, 23 Apr 2019 09:40:43 +0800 Subject: [PATCH] network: pass network interface RawFlags to agent In order to support NOARP in ipvlan interface, the runtime will pass the rawflags to agent, which also apply to other network interfaces, not just ipvlan. Fixes: #1391 Signed-off-by: Zha Bin --- Gopkg.lock | 8 +- Gopkg.toml | 2 +- .../agent/pkg/types/types.pb.go | 82 +++++++++++++------ virtcontainers/kata_agent.go | 1 + virtcontainers/network.go | 2 + virtcontainers/pkg/types/types.go | 1 + 6 files changed, 68 insertions(+), 28 deletions(-) diff --git a/Gopkg.lock b/Gopkg.lock index 1a3ed2f9e4..fd7ea6b329 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -395,7 +395,7 @@ revision = "35a8fd3ca9a36461b7dcf24e3b292f6e1ea4e71a" [[projects]] - digest = "1:eaa44c90711ae244bae3ef4239edc720bbbd7dfc754bfdbd12407bdaf14d6777" + digest = "1:36dfd4701e98a9d8371dd3053e32d4f29e82b07bcc9e655db82138f9273bcb0f" name = "github.com/kata-containers/agent" packages = [ "pkg/types", @@ -403,7 +403,7 @@ "protocols/grpc", ] pruneopts = "NUT" - revision = "17192be88b2725b0e7f482a8b7616935e1b1ddf4" + revision = "48dd1c031530fce9bf16b0f6a7305979cedd8fc9" [[projects]] digest = "1:04054595e5c5a35d1553a7f3464d18577caf597445d643992998643df56d4afd" @@ -425,11 +425,11 @@ revision = "6243d8e04c3f819e79757e8bc3faa15c3cb27003" [[projects]] - digest = "1:0159dcdabe50788e5dcfb469521f8f8dcd362db3ab6b465b99a3d33a90726fc0" + digest = "1:f3e11773cc8a305f97b42c276f62d92899c9b0c1c3c584a667149b18f18a530a" name = "github.com/mdlayher/vsock" packages = ["."] pruneopts = "NUT" - revision = "738c88d6e4cfd60e8124a5344fa10d205fd828b9" + revision = "676f733b747cd6406f297a51bd086ee8ec8abdbe" [[projects]] digest = "1:6a65dcd0d14fc0595ee982afc3c59deb5b769ca374455c80c649d92f8a152930" diff --git a/Gopkg.toml b/Gopkg.toml index bd41625d3c..803d5092c3 100644 --- a/Gopkg.toml +++ b/Gopkg.toml @@ -56,7 +56,7 @@ [[constraint]] name = "github.com/kata-containers/agent" - revision = "17192be88b2725b0e7f482a8b7616935e1b1ddf4" + revision = "48dd1c031530fce9bf16b0f6a7305979cedd8fc9" [[constraint]] name = "github.com/containerd/cri-containerd" diff --git a/vendor/github.com/kata-containers/agent/pkg/types/types.pb.go b/vendor/github.com/kata-containers/agent/pkg/types/types.pb.go index 779eee10b1..7ea63e3c0e 100644 --- a/vendor/github.com/kata-containers/agent/pkg/types/types.pb.go +++ b/vendor/github.com/kata-containers/agent/pkg/types/types.pb.go @@ -98,7 +98,8 @@ type Interface struct { // The expected values are the one that are defined by the netlink // library, regarding each type of link. Here is a non exhaustive // list: "veth", "macvtap", "vlan", "macvlan", "tap", ... - Type string `protobuf:"bytes,7,opt,name=type,proto3" json:"type,omitempty"` + Type string `protobuf:"bytes,7,opt,name=type,proto3" json:"type,omitempty"` + RawFlags uint32 `protobuf:"varint,8,opt,name=raw_flags,json=rawFlags,proto3" json:"raw_flags,omitempty"` } func (m *Interface) Reset() { *m = Interface{} } @@ -155,6 +156,13 @@ func (m *Interface) GetType() string { return "" } +func (m *Interface) GetRawFlags() uint32 { + if m != nil { + return m.RawFlags + } + return 0 +} + type Route struct { Dest string `protobuf:"bytes,1,opt,name=dest,proto3" json:"dest,omitempty"` Gateway string `protobuf:"bytes,2,opt,name=gateway,proto3" json:"gateway,omitempty"` @@ -306,6 +314,11 @@ func (m *Interface) MarshalTo(dAtA []byte) (int, error) { i = encodeVarintTypes(dAtA, i, uint64(len(m.Type))) i += copy(dAtA[i:], m.Type) } + if m.RawFlags != 0 { + dAtA[i] = 0x40 + i++ + i = encodeVarintTypes(dAtA, i, uint64(m.RawFlags)) + } return i, nil } @@ -414,6 +427,9 @@ func (m *Interface) Size() (n int) { if l > 0 { n += 1 + l + sovTypes(uint64(l)) } + if m.RawFlags != 0 { + n += 1 + sovTypes(uint64(m.RawFlags)) + } return n } @@ -806,6 +822,25 @@ func (m *Interface) Unmarshal(dAtA []byte) error { } m.Type = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex + case 8: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field RawFlags", wireType) + } + m.RawFlags = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.RawFlags |= (uint32(b) & 0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipTypes(dAtA[iNdEx:]) @@ -1120,26 +1155,27 @@ var ( func init() { proto.RegisterFile("pkg/types/types.proto", fileDescriptorTypes) } var fileDescriptorTypes = []byte{ - // 325 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x54, 0x91, 0x4f, 0x6e, 0xf2, 0x30, - 0x10, 0xc5, 0x3f, 0x13, 0x12, 0xbe, 0x0c, 0xfd, 0x13, 0x59, 0x2d, 0xb2, 0xba, 0x40, 0x11, 0x9b, - 0x46, 0x5d, 0x50, 0x89, 0x56, 0xdd, 0xb7, 0x8b, 0x4a, 0xec, 0x90, 0x6f, 0x60, 0x92, 0x81, 0x22, - 0x1a, 0x12, 0xc5, 0x06, 0x84, 0x7a, 0xbc, 0x6e, 0xba, 0xec, 0x11, 0x2a, 0x4e, 0x52, 0x79, 0x6c, - 0x10, 0xdd, 0x24, 0xef, 0x79, 0x3c, 0x9e, 0xdf, 0xb3, 0xe1, 0xba, 0x5e, 0xce, 0xef, 0xcd, 0xae, - 0x46, 0xed, 0xbe, 0xc3, 0xba, 0xa9, 0x4c, 0xc5, 0x43, 0x32, 0x83, 0x29, 0xc4, 0xe3, 0xc9, 0x73, - 0x51, 0x34, 0xa8, 0x35, 0xbf,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 0x82, 0xd6, 0xe6, - 0x31, 0xf9, 0x47, 0xff, 0xa7, 0x84, 0xbd, 0x9c, 0x7d, 0xed, 0xfb, 0xec, 0x7b, 0xdf, 0x67, 0x3f, - 0xfb, 0x3e, 0x9b, 0x46, 0xf4, 0xbc, 0x0f, 0xbf, 0x01, 0x00, 0x00, 0xff, 0xff, 0x13, 0xcc, 0x1c, - 0xcc, 0xf7, 0x01, 0x00, 0x00, + // 345 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x54, 0x91, 0xd1, 0x6a, 0xfa, 0x30, + 0x14, 0xc6, 0xff, 0xb1, 0xb6, 0xda, 0xe3, 0xdf, 0xad, 0x84, 0x4d, 0xc2, 0x06, 0x52, 0xbc, 0x59, + 0xd9, 0x85, 0x03, 0x37, 0x76, 0xbf, 0x5d, 0x08, 0xde, 0x49, 0x5e, 0x60, 0xc4, 0x36, 0x3a, 0xd1, + 0xda, 0xd2, 0x44, 0x8b, 0xec, 0x05, 0x77, 0xb9, 0x47, 0x10, 0x9f, 0x64, 0xe4, 0x24, 0x8a, 0xbb, + 0xd1, 0xef, 0x97, 0x93, 0xd3, 0xef, 0x7c, 0x27, 0x70, 0x5b, 0xae, 0x16, 0x4f, 0x7a, 0x5f, 0x4a, + 0x65, 0x7f, 0x87, 0x65, 0x55, 0xe8, 0x82, 0xfa, 0x08, 0x83, 0x19, 0x84, 0x93, 0xe9, 0x5b, 0x96, + 0x55, 0x52, 0x29, 0xfa, 0x00, 0xc1, 0x5c, 0xe4, 0xcb, 0xf5, 0x9e, 0x91, 0x98, 0x24, 0x57, 0xa3, + 0xeb, 0xa1, 0xed, 0x98, 0x4c, 0xc7, 0x78, 0xcc, 0x5d, 0x99, 0x32, 0x68, 0x09, 0xdb, 0xc3, 0x1a, + 0x31, 0x49, 0x42, 0x7e, 0x42, 0x4a, 0xa1, 0x99, 0x0b, 0xb5, 0x62, 0x1e, 0x1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d8, 0x27, 0x87, 0x63, 0x9f, 0xcc, 0x02, 0x7c, 0xfb, 0xe7, 0xdf, 0x00, 0x00, 0x00, 0xff, + 0xff, 0xb5, 0x52, 0x37, 0xf2, 0x14, 0x02, 0x00, 0x00, } diff --git a/virtcontainers/kata_agent.go b/virtcontainers/kata_agent.go index 0eefca10b6..e5f2844be2 100644 --- a/virtcontainers/kata_agent.go +++ b/virtcontainers/kata_agent.go @@ -1789,6 +1789,7 @@ func (k *kataAgent) convertToKataAgentInterface(iface *vcTypes.Interface) *aType Name: iface.Name, IPAddresses: k.convertToKataAgentIPAddresses(iface.IPAddresses), Mtu: iface.Mtu, + RawFlags: iface.RawFlags, HwAddr: iface.HwAddr, PciAddr: iface.PciAddr, } diff --git a/virtcontainers/network.go b/virtcontainers/network.go index 511a18ca35..ff7dd26935 100644 --- a/virtcontainers/network.go +++ b/virtcontainers/network.go @@ -1143,11 +1143,13 @@ func generateInterfacesAndRoutes(networkNS NetworkNamespace) ([]*vcTypes.Interfa } ipAddresses = append(ipAddresses, &ipAddress) } + noarp := endpoint.Properties().Iface.RawFlags & unix.IFF_NOARP ifc := vcTypes.Interface{ IPAddresses: ipAddresses, Device: endpoint.Name(), Name: endpoint.Name(), Mtu: uint64(endpoint.Properties().Iface.MTU), + RawFlags: noarp, HwAddr: endpoint.HardwareAddr(), PciAddr: endpoint.PciAddr(), } diff --git a/virtcontainers/pkg/types/types.go b/virtcontainers/pkg/types/types.go index 9fd0b201a4..0d4a9cfa13 100644 --- a/virtcontainers/pkg/types/types.go +++ b/virtcontainers/pkg/types/types.go @@ -18,6 +18,7 @@ type Interface struct { Name string IPAddresses []*IPAddress Mtu uint64 + RawFlags uint32 HwAddr string // pciAddr is the PCI address in the format "bridgeAddr/deviceAddr". // Here, bridgeAddr is the address at which the bridge is attached on the root bus,