Skip to content

Commit

Permalink
[-] make "no IPv4 address available for interface" a warning, fixes #231
Browse files Browse the repository at this point in the history
 (#246)
  • Loading branch information
pashagolub authored Jul 25, 2024
1 parent 4ffa437 commit 963afe4
Showing 1 changed file with 11 additions and 17 deletions.
28 changes: 11 additions & 17 deletions ipmanager/basicConfigurer_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@ var (
// configureAddress assigns virtual IP address
func (c *BasicConfigurer) configureAddress() bool {
if c.arpClient == nil {
err := c.createArpClient()
if err != nil {
log.Fatalf("Couldn't create an Arp client: %s", err)
if err := c.createArpClient(); err != nil {
log.Printf("Couldn't create an Arp client: %s", err)
}
}

Expand Down Expand Up @@ -67,24 +66,15 @@ func (c *BasicConfigurer) runAddressConfiguration(action string) bool {
return true
}

func (c *BasicConfigurer) createArpClient() error {
var err error
var arpClient *arp.Client
func (c *BasicConfigurer) createArpClient() (err error) {
for i := 0; i < c.RetryNum; i++ {
arpClient, err = arp.Dial(&c.Iface)
if err != nil {
log.Printf("Problems with producing the arp client: %s", err)
} else {
break
if c.arpClient, err = arp.Dial(&c.Iface); err == nil {
return
}
log.Printf("Problems with producing the arp client: %s", err)
time.Sleep(time.Duration(c.RetryAfter) * time.Millisecond)
}
if err != nil {
log.Print("too many retries")
return err
}
c.arpClient = arpClient
return nil
return
}

// sends a gratuitous ARP request and reply
Expand All @@ -95,6 +85,10 @@ func (c *BasicConfigurer) arpSendGratuitous() error {
* This site also recommends sending a reply, as requests might be ignored by some hardware:
* https://support.citrix.com/article/CTX112701
*/
if c.arpClient == nil {
log.Println("No arp client available, skip send gratuitous ARP")
return nil
}
gratuitousReplyPackage, err := arp.NewPacket(
arpReplyOp,
c.Iface.HardwareAddr,
Expand Down

0 comments on commit 963afe4

Please sign in to comment.