2121// configureAddress assigns virtual IP address
2222func (c * BasicConfigurer ) configureAddress () bool {
2323 if c .arpClient == nil {
24- err := c .createArpClient ()
25- if err != nil {
26- log .Fatalf ("Couldn't create an Arp client: %s" , err )
24+ if err := c .createArpClient (); err != nil {
25+ log .Printf ("Couldn't create an Arp client: %s" , err )
2726 }
2827 }
2928
@@ -67,24 +66,15 @@ func (c *BasicConfigurer) runAddressConfiguration(action string) bool {
6766 return true
6867}
6968
70- func (c * BasicConfigurer ) createArpClient () error {
71- var err error
72- var arpClient * arp.Client
69+ func (c * BasicConfigurer ) createArpClient () (err error ) {
7370 for i := 0 ; i < c .RetryNum ; i ++ {
74- arpClient , err = arp .Dial (& c .Iface )
75- if err != nil {
76- log .Printf ("Problems with producing the arp client: %s" , err )
77- } else {
78- break
71+ if c .arpClient , err = arp .Dial (& c .Iface ); err == nil {
72+ return
7973 }
74+ log .Printf ("Problems with producing the arp client: %s" , err )
8075 time .Sleep (time .Duration (c .RetryAfter ) * time .Millisecond )
8176 }
82- if err != nil {
83- log .Print ("too many retries" )
84- return err
85- }
86- c .arpClient = arpClient
87- return nil
77+ return
8878}
8979
9080// sends a gratuitous ARP request and reply
@@ -95,6 +85,10 @@ func (c *BasicConfigurer) arpSendGratuitous() error {
9585 * This site also recommends sending a reply, as requests might be ignored by some hardware:
9686 * https://support.citrix.com/article/CTX112701
9787 */
88+ if c .arpClient == nil {
89+ log .Println ("No arp client available, skip send gratuitous ARP" )
90+ return nil
91+ }
9892 gratuitousReplyPackage , err := arp .NewPacket (
9993 arpReplyOp ,
10094 c .Iface .HardwareAddr ,
0 commit comments