Skip to content

Commit

Permalink
Merge pull request #34 from telekom/configurable-neigh-suppression
Browse files Browse the repository at this point in the history
Make Neighbor Suppression configurable
  • Loading branch information
chdxD1 committed Jul 19, 2023
2 parents 96ef803 + d75c9a3 commit 2faccc6
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 4 deletions.
3 changes: 3 additions & 0 deletions api/v1alpha1/layer2networkconfiguration_types.go
Expand Up @@ -53,6 +53,9 @@ type Layer2NetworkConfigurationSpec struct {
// Create MACVLAN attach interface
CreateMACVLANInterface bool `json:"createMacVLANInterface,omitempty"`

// Enable ARP / ND suppression
NeighSuppression *bool `json:"neighSuppression,omitempty"`

// VRF to attach Layer2 network to, default if not set
VRF string `json:"vrf,omitempty"`

Expand Down
5 changes: 5 additions & 0 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Expand Up @@ -62,6 +62,9 @@ spec:
maximum: 9000
minimum: 1000
type: integer
neighSuppression:
description: Enable ARP / ND suppression
type: boolean
nodeSelector:
description: Select nodes to create Layer2 network on
properties:
Expand Down
4 changes: 2 additions & 2 deletions pkg/nl/create.go
Expand Up @@ -57,7 +57,7 @@ func (n *NetlinkManager) createBridge(bridgeName string, macAddress *net.Hardwar
return &netlinkBridge, nil
}

func (n *NetlinkManager) createVXLAN(vxlanName string, bridgeIdx int, vni int, mtu int, hairpin bool) (*netlink.Vxlan, error) {
func (n *NetlinkManager) createVXLAN(vxlanName string, bridgeIdx int, vni int, mtu int, hairpin bool, neighSuppression bool) (*netlink.Vxlan, error) {
vxlanIf, vxlanIP, err := getInterfaceAndIP(UNDERLAY_LOOPBACK)
if err != nil {
return nil, err
Expand Down Expand Up @@ -87,7 +87,7 @@ func (n *NetlinkManager) createVXLAN(vxlanName string, bridgeIdx int, vni int, m
if err := netlink.LinkSetLearning(&netlinkVXLAN, false); err != nil {
return nil, err
}
if err := setNeighSuppression(&netlinkVXLAN, os.Getenv("NWOP_NEIGH_SUPPRESSION") == "true"); err != nil {
if err := setNeighSuppression(&netlinkVXLAN, neighSuppression); err != nil {
return nil, err
}
if hairpin {
Expand Down
18 changes: 17 additions & 1 deletion pkg/nl/layer2.go
Expand Up @@ -19,6 +19,7 @@ type Layer2Information struct {
AnycastMAC *net.HardwareAddr
AnycastGateways []*netlink.Addr
AdvertiseNeighbors bool
NeighSuppression *bool

CreateMACVLANInterface bool

Expand Down Expand Up @@ -75,12 +76,20 @@ func (n *NetlinkManager) CreateL2(info Layer2Information) error {
}
}

neighSuppression := os.Getenv("NWOP_NEIGH_SUPPRESSION") == "true"
if len(info.AnycastGateways) == 0 {
neighSuppression = false
}
if info.NeighSuppression != nil {
neighSuppression = *info.NeighSuppression
}
vxlan, err := n.createVXLAN(
fmt.Sprintf("%s%d", VXLAN_PREFIX, info.VNI),
bridge.Attrs().Index,
info.VNI,
info.MTU,
false,
neighSuppression,
)
if err != nil {
return err
Expand Down Expand Up @@ -277,7 +286,14 @@ func (n *NetlinkManager) ReconcileL2(current Layer2Information, desired Layer2In
if err := n.configureBridge(fmt.Sprintf("%s%d", LAYER2_PREFIX, current.VlanID)); err != nil {
return err
}
if err := setNeighSuppression(current.vxlan, os.Getenv("NWOP_NEIGH_SUPPRESSION") == "true"); err != nil {
neighSuppression := os.Getenv("NWOP_NEIGH_SUPPRESSION") == "true"
if len(desired.AnycastGateways) == 0 {
neighSuppression = false
}
if desired.NeighSuppression != nil {
neighSuppression = *desired.NeighSuppression
}
if err := setNeighSuppression(current.vxlan, neighSuppression); err != nil {
return err
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/nl/layer3.go
Expand Up @@ -48,7 +48,7 @@ func (n *NetlinkManager) CreateL3(info VRFInformation) error {
return err
}

vxlan, err := n.createVXLAN(VXLAN_PREFIX+info.Name, bridge.Attrs().Index, info.VNI, DEFAULT_MTU, true)
vxlan, err := n.createVXLAN(VXLAN_PREFIX+info.Name, bridge.Attrs().Index, info.VNI, DEFAULT_MTU, true, false)
if err != nil {
return err
}
Expand Down
1 change: 1 addition & 0 deletions pkg/reconciler/layer2.go
Expand Up @@ -76,6 +76,7 @@ func (r *reconcile) reconcileLayer2(l2vnis []networkv1alpha1.Layer2NetworkConfig
AnycastMAC: anycastMAC,
AnycastGateways: anycastGateways,
AdvertiseNeighbors: spec.AdvertiseNeighbors,
NeighSuppression: spec.NeighSuppression,
CreateMACVLANInterface: spec.CreateMACVLANInterface,
})
}
Expand Down

0 comments on commit 2faccc6

Please sign in to comment.