Skip to content

Commit

Permalink
Interface IPv6 addresses are routable, announce them to public VNI
Browse files Browse the repository at this point in the history
Signed-off-by: Guvenc Gulce <guevenc.guelce@sap.com>
  • Loading branch information
guvenc committed Feb 13, 2024
1 parent f51f52e commit ef8ea11
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions controllers/networkinterface_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,11 +229,18 @@ func (r *NetworkInterfaceReconciler) addInterfaceRouteIfNotExists(ctx context.Co
return nil
}

func (r *NetworkInterfaceReconciler) addInterfaceRoutesIfNotExist(ctx context.Context, vni uint32, ips []netip.Addr, underlayRoute netip.Addr) error {
func (r *NetworkInterfaceReconciler) addInterfaceRoutesIfNotExist(ctx context.Context, log logr.Logger, vni uint32, ips []netip.Addr, underlayRoute netip.Addr) error {
for _, localAddr := range ips {
if err := r.addInterfaceRouteIfNotExists(ctx, vni, localAddr, underlayRoute); err != nil {
return fmt.Errorf("[local address %s] %w", localAddr, err)
}
if localAddr.Is6() {
log.V(1).Info("Adding routable ipv6 route if not exists")
if err := r.addVirtualIPRouteIfNotExists(ctx, localAddr, underlayRoute); err != nil {
return err
}
log.V(1).Info("Added routable ipv6 route if not existed")
}
}
return nil
}
Expand All @@ -250,11 +257,18 @@ func (r *NetworkInterfaceReconciler) removeInterfaceRouteIfExists(ctx context.Co
return nil
}

func (r *NetworkInterfaceReconciler) removeInterfaceRoutesIfExist(ctx context.Context, vni uint32, ips []netip.Addr, underlayRoute netip.Addr) error {
func (r *NetworkInterfaceReconciler) removeInterfaceRoutesIfExist(ctx context.Context, log logr.Logger, vni uint32, ips []netip.Addr, underlayRoute netip.Addr) error {
for _, localAddr := range ips {
if err := r.removeInterfaceRouteIfExists(ctx, vni, localAddr, underlayRoute); err != nil {
return fmt.Errorf("[local address %s] %w", localAddr, err)
}
if localAddr.Is6() {
log.V(1).Info("Removing routable ipv6 route if exists")
if err := r.removeVirtualIPRouteIfExists(ctx, localAddr, underlayRoute); err != nil {
return err
}
log.V(1).Info("Removed routable ipv6 route if existed")
}
}
return nil
}
Expand Down Expand Up @@ -1265,7 +1279,7 @@ func (r *NetworkInterfaceReconciler) applyInterface(ctx context.Context, log log
}
log.V(1).Info("Adding interface routes if not exist")
ips := getNetworkInterfaceIPs(nic)
if err := r.addInterfaceRoutesIfNotExist(ctx, vni, ips, *iface.Spec.UnderlayRoute); err != nil {
if err := r.addInterfaceRoutesIfNotExist(ctx, log, vni, ips, *iface.Spec.UnderlayRoute); err != nil {
return nil, netip.Addr{}, false, err
}
log.V(1).Info("Added interface routes if not existed")
Expand All @@ -1283,7 +1297,7 @@ func (r *NetworkInterfaceReconciler) applyInterface(ctx context.Context, log log

log.V(1).Info("Adding interface route if not exists")
ips := getNetworkInterfaceIPs(nic)
if err := r.addInterfaceRoutesIfNotExist(ctx, vni, ips, *iface.Spec.UnderlayRoute); err != nil {
if err := r.addInterfaceRoutesIfNotExist(ctx, log, vni, ips, *iface.Spec.UnderlayRoute); err != nil {
return nil, netip.Addr{}, false, err
}
log.V(1).Info("Added interface route if not existed")
Expand Down Expand Up @@ -1558,7 +1572,7 @@ func (r *NetworkInterfaceReconciler) deleteInterface(
) error {
log.V(1).Info("Removing interface route if exists")
ips := getNetworkInterfaceIPs(nic)
if err := r.removeInterfaceRoutesIfExist(ctx, vni, ips, underlayRoute); err != nil {
if err := r.removeInterfaceRoutesIfExist(ctx, log, vni, ips, underlayRoute); err != nil {
return err
}
log.V(1).Info("Removed interface route if existed")
Expand Down

0 comments on commit ef8ea11

Please sign in to comment.