@@ -1255,14 +1255,18 @@ func (o *NB) UpdateLogicalSwitchDHCPv4Options(ctx context.Context, switchName OV
1255
1255
1256
1256
if opts .Router != nil {
1257
1257
dhcpOption .Options ["router" ] = opts .Router .String ()
1258
+ } else {
1259
+ delete (dhcpOption .Options , "router" )
1258
1260
}
1259
1261
1260
1262
if len (opts .DNSSearchList ) > 0 {
1261
1263
// Special quoting to allow domain names.
1262
1264
dhcpOption .Options ["domain_search_list" ] = fmt .Sprintf (`"%s"` , strings .Join (opts .DNSSearchList , "," ))
1265
+ } else {
1266
+ delete (dhcpOption .Options , "domain_search_list" )
1263
1267
}
1264
1268
1265
- if opts .RecursiveDNSServer != nil {
1269
+ if len ( opts .RecursiveDNSServer ) > 0 {
1266
1270
nsIPs := make ([]string , 0 , len (opts .RecursiveDNSServer ))
1267
1271
for _ , nsIP := range opts .RecursiveDNSServer {
1268
1272
if nsIP .To4 () == nil {
@@ -1273,19 +1277,27 @@ func (o *NB) UpdateLogicalSwitchDHCPv4Options(ctx context.Context, switchName OV
1273
1277
}
1274
1278
1275
1279
dhcpOption .Options ["dns_server" ] = fmt .Sprintf ("{%s}" , strings .Join (nsIPs , "," ))
1280
+ } else {
1281
+ delete (dhcpOption .Options , "dns_server" )
1276
1282
}
1277
1283
1278
1284
if opts .DomainName != "" {
1279
1285
// Special quoting to allow domain names.
1280
1286
dhcpOption .Options ["domain_name" ] = fmt .Sprintf (`"%s"` , opts .DomainName )
1287
+ } else {
1288
+ delete (dhcpOption .Options , "domain_name" )
1281
1289
}
1282
1290
1283
1291
if opts .MTU > 0 {
1284
1292
dhcpOption .Options ["mtu" ] = fmt .Sprintf ("%d" , opts .MTU )
1293
+ } else {
1294
+ delete (dhcpOption .Options , "mtu" )
1285
1295
}
1286
1296
1287
1297
if opts .Netmask != "" {
1288
1298
dhcpOption .Options ["netmask" ] = opts .Netmask
1299
+ } else {
1300
+ delete (dhcpOption .Options , "netmask" )
1289
1301
}
1290
1302
1291
1303
if opts .StaticRoutes != "" {
0 commit comments