@@ -472,7 +472,7 @@ func (r *infraIPAllocator) allocateHealthIPs(ctx context.Context, oldV4HealthIP
472472 return nil
473473}
474474
475- func (r * infraIPAllocator ) allocateIngressIPs (ctx context.Context , oldV4IngressIP net. IP , oldV6IngressIP net. IP ) error {
475+ func (r * infraIPAllocator ) allocateIngressIPs (ctx context.Context , oldV4IngressIP netip. Addr , oldV6IngressIP netip. Addr ) error {
476476 if ! r .daemonConfig .EnableEnvoyConfig {
477477 return nil
478478 }
@@ -483,8 +483,8 @@ func (r *infraIPAllocator) allocateIngressIPs(ctx context.Context, oldV4IngressI
483483 var err error
484484
485485 // Reallocate the same address as before, if possible
486- if ingressIPv4 != nil {
487- result , err = r .ipAllocator .AllocateIPWithoutSyncUpstream (iputil . AddrFromIP ( ingressIPv4 ) , "ingress" , ipam .PoolDefault ())
486+ if ingressIPv4 . IsValid () {
487+ result , err = r .ipAllocator .AllocateIPWithoutSyncUpstream (ingressIPv4 , "ingress" , ipam .PoolDefault ())
488488 if err != nil {
489489 r .logger .Warn ("unable to re-allocate ingress IPv4." ,
490490 logfields .Error , err ,
@@ -511,8 +511,8 @@ func (r *infraIPAllocator) allocateIngressIPs(ctx context.Context, oldV4IngressI
511511 result .CIDRs = r .coalesceCIDRs (result .CIDRs )
512512 }
513513
514- ingressIPv4 = net . IP ( result .IP . AsSlice ()). To16 ()
515- r .localNodeStore .Update (func (n * node.LocalNode ) { n .IPv4IngressIP = net . IP (result .IP . AsSlice ()). To16 ( ) })
514+ ingressIPv4 = result .IP
515+ r .localNodeStore .Update (func (n * node.LocalNode ) { n .IPv4IngressIP = iputil . AddrFrom (result .IP ) })
516516 r .logger .Debug ("Allocated IPv4 Ingress address" , logfields .IPAddr , result .IP )
517517
518518 // In ENI and AlibabaCloud ENI mode, we require the gateway, CIDRs, and the
@@ -549,8 +549,8 @@ func (r *infraIPAllocator) allocateIngressIPs(ctx context.Context, oldV4IngressI
549549
550550 // Reallocate the same address as before, if possible
551551 ingressIPv6 := oldV6IngressIP
552- if ingressIPv6 != nil {
553- result , err = r .ipAllocator .AllocateIPWithoutSyncUpstream (iputil . AddrFromIP ( ingressIPv6 ) , "ingress" , ipam .PoolDefault ())
552+ if ingressIPv6 . IsValid () {
553+ result , err = r .ipAllocator .AllocateIPWithoutSyncUpstream (ingressIPv6 , "ingress" , ipam .PoolDefault ())
554554 if err != nil {
555555 r .logger .Warn ("unable to re-allocate ingress IPv6." ,
556556 logfields .Error , err ,
@@ -565,9 +565,9 @@ func (r *infraIPAllocator) allocateIngressIPs(ctx context.Context, oldV4IngressI
565565 if result == nil {
566566 result , err = r .allocateNextFromPool (ctx , ipam .IPv6 , "ingress" )
567567 if err != nil {
568- if ingressIPv4 != nil {
569- r .ipAllocator .ReleaseIP (iputil . AddrFromIP ( ingressIPv4 ) , ipam .PoolDefault ())
570- r .localNodeStore .Update (func (n * node.LocalNode ) { n .IPv4IngressIP = nil })
568+ if ingressIPv4 . IsValid () {
569+ r .ipAllocator .ReleaseIP (ingressIPv4 , ipam .PoolDefault ())
570+ r .localNodeStore .Update (func (n * node.LocalNode ) { n .IPv4IngressIP = iputil. Addr {} })
571571 }
572572 return fmt .Errorf ("unable to allocate ingress IPs: %w, see https://cilium.link/ipam-range-full" , err )
573573 }
@@ -581,7 +581,7 @@ func (r *infraIPAllocator) allocateIngressIPs(ctx context.Context, oldV4IngressI
581581 result .CIDRs = r .coalesceCIDRs (result .CIDRs )
582582 }
583583
584- r .localNodeStore .Update (func (n * node.LocalNode ) { n .IPv6IngressIP = net . IP (result .IP . AsSlice ()). To16 ( ) })
584+ r .localNodeStore .Update (func (n * node.LocalNode ) { n .IPv6IngressIP = iputil . AddrFrom (result .IP ) })
585585 r .logger .Debug ("Allocated IPv6 Ingress address" , logfields .IPAddr , result .IP )
586586 }
587587
@@ -609,7 +609,7 @@ func (r *infraIPAllocator) AllocateIPs(ctx context.Context) error {
609609 return fmt .Errorf ("failed to allocate service loopback IPs: %w" , err )
610610 }
611611
612- if err := r .allocateIngressIPs (ctx , localNode .IPv4IngressIP , localNode .IPv6IngressIP ); err != nil {
612+ if err := r .allocateIngressIPs (ctx , localNode .IPv4IngressIP . Addr , localNode .IPv6IngressIP . Addr ); err != nil {
613613 return fmt .Errorf ("failed to allocate ingress IPs: %w" , err )
614614 }
615615
0 commit comments