@@ -562,6 +562,15 @@ func (d *OvsDriver) DeleteNetwork(value string) error {
562
562
}
563
563
}
564
564
565
+ if cfgNetState .SubnetIp == "auto" {
566
+ log .Printf ("freeing subnet %s/%d \n " ,
567
+ operNwState .SubnetIp , operNwState .SubnetLen )
568
+ err = gOper .FreeSubnet (operNwState .SubnetIp )
569
+ if err != nil {
570
+ log .Printf ("error '%s' freeing the subnet \n " , err )
571
+ }
572
+ }
573
+
565
574
err = gOper .Update (d .stateDriver )
566
575
if err != nil {
567
576
log .Printf ("error updating the global state - %s \n " , err )
@@ -713,7 +722,6 @@ func (d *OvsDriver) CreateEndpoint(id string) error {
713
722
log .Printf ("error acquiring subnet ip '%s' \n " , err )
714
723
return err
715
724
}
716
- operNwState .IpAllocMap .Set (ipAddrBit )
717
725
log .Printf ("Ep %s was allocated ip address %s \n " , id , ipAddress )
718
726
} else if ipAddress != "" && operNwState .SubnetIp != "" {
719
727
ipAddrBit , err = netutils .GetIpNumber (
@@ -723,8 +731,8 @@ func (d *OvsDriver) CreateEndpoint(id string) error {
723
731
ipAddress , operNwState .SubnetIp , operNwState .SubnetLen , err )
724
732
return err
725
733
}
726
- operNwState .IpAllocMap .Set (ipAddrBit )
727
734
}
735
+ operNwState .IpAllocMap .Set (ipAddrBit )
728
736
729
737
// deprecate - bitset.WordCount gives the following value
730
738
operNwState .EpCount += 1
@@ -740,7 +748,6 @@ func (d *OvsDriver) CreateEndpoint(id string) error {
740
748
}
741
749
}()
742
750
743
- //all went well, update the runtime state of network and endpoint
744
751
operEpState := OvsOperEndpointState {
745
752
StateDriver : d .stateDriver ,
746
753
Id : id ,
@@ -791,7 +798,6 @@ func (d *OvsDriver) DeleteEndpoint(value string) (err error) {
791
798
epOper .Clear ()
792
799
}()
793
800
794
- // delete the internal ovs port corresponding to the endpoint
795
801
portName , err := d .getPortOrIntfNameFromId (epCfg .Id , GET_PORT_NAME )
796
802
if err != nil {
797
803
return err
@@ -814,6 +820,15 @@ func (d *OvsDriver) DeleteEndpoint(value string) (err error) {
814
820
return err
815
821
}
816
822
823
+ ipAddrBit , err := netutils .GetIpNumber (
824
+ operNwState .SubnetIp , operNwState .SubnetLen , 32 , epOper .IpAddress )
825
+ if err != nil {
826
+ log .Printf ("error getting host id from %s subnet %s/%d err '%s'\n " ,
827
+ epOper .IpAddress , operNwState .SubnetIp , operNwState .SubnetLen , err )
828
+ } else {
829
+ operNwState .IpAllocMap .Clear (ipAddrBit )
830
+ }
831
+
817
832
operNwState .EpCount -= 1
818
833
err = operNwState .Write ()
819
834
if err != nil {
0 commit comments