diff --git a/network/types.go b/network/types.go index dcf00420f..a1668e06c 100644 --- a/network/types.go +++ b/network/types.go @@ -38,6 +38,12 @@ type Network struct { // container's interfaces if a pair is created, specifically in the case of type veth // Note: This does not apply to loopback interfaces. TxQueueLen int `json:"txqueuelen,omitempty"` + + // HairpinMode specifies if hairpin NAT should be enabled on the virtual interface + // bridge port in the case of type veth + // Note: This is unsupported on some systems. + // Note: This does not apply to loopback interfaces. + HairpinMode bool `json:"hairpin_mode"` } // Struct describing the network specific runtime state that will be maintained by libcontainer for all running containers diff --git a/network/veth.go b/network/veth.go index 3d7dc8729..25e559d1b 100644 --- a/network/veth.go +++ b/network/veth.go @@ -39,6 +39,11 @@ func (v *Veth) Create(n *Network, nspid int, networkState *NetworkState) error { if err := SetMtu(name1, n.Mtu); err != nil { return err } + if n.HairpinMode { + if err := SetHairpinMode(name1, true); err != nil { + return err + } + } if err := InterfaceUp(name1); err != nil { return err }