Skip to content

Commit

Permalink
ipam: Do not report error for static assigned IPs.
Browse files Browse the repository at this point in the history
Do not report error in ipam_insert_ip routine for addresses
statically assigned to ovn logical {switch,router} ports since they
have precedence on addressed dynamically assigned by ipam.

Reported-at: https://issues.redhat.com/browse/FDP-752
Signed-off-by: Lorenzo Bianconi <[email protected]>
Acked-by: Mark Michelson <[email protected]>
Signed-off-by: Numan Siddique <[email protected]>
  • Loading branch information
LorenzoBianconi authored and numansiddique committed Oct 17, 2024
1 parent 9631ce7 commit 12886fb
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
6 changes: 3 additions & 3 deletions northd/ipam.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,16 @@ destroy_ipam_info(struct ipam_info *info)
}

bool
ipam_insert_ip(struct ipam_info *info, uint32_t ip)
ipam_insert_ip(struct ipam_info *info, uint32_t ip, bool dynamic)
{
if (!info->allocated_ipv4s) {
return true;
}

if (ip >= info->start_ipv4 &&
ip < (info->start_ipv4 + info->total_ipv4s)) {
if (bitmap_is_set(info->allocated_ipv4s,
ip - info->start_ipv4)) {
if (dynamic && bitmap_is_set(info->allocated_ipv4s,
ip - info->start_ipv4)) {
static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 1);
VLOG_WARN_RL(&rl, "%s: Duplicate IP set: " IP_FMT,
info->id, IP_ARGS(htonl(ip)));
Expand Down
2 changes: 1 addition & 1 deletion northd/ipam.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ void init_ipam_info(struct ipam_info *info, const struct smap *config,

void destroy_ipam_info(struct ipam_info *info);

bool ipam_insert_ip(struct ipam_info *info, uint32_t ip);
bool ipam_insert_ip(struct ipam_info *info, uint32_t ip, bool dynamic);

uint32_t ipam_get_unused_ip(struct ipam_info *info);

Expand Down
13 changes: 7 additions & 6 deletions northd/northd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1464,13 +1464,13 @@ ovn_port_get_peer(const struct hmap *lr_ports, struct ovn_port *op)
}

static void
ipam_insert_ip_for_datapath(struct ovn_datapath *od, uint32_t ip)
ipam_insert_ip_for_datapath(struct ovn_datapath *od, uint32_t ip, bool dynamic)
{
if (!od) {
return;
}

ipam_insert_ip(&od->ipam_info, ip);
ipam_insert_ip(&od->ipam_info, ip, dynamic);
}

static void
Expand All @@ -1487,7 +1487,7 @@ ipam_insert_lsp_addresses(struct ovn_datapath *od,

for (size_t j = 0; j < laddrs->n_ipv4_addrs; j++) {
uint32_t ip = ntohl(laddrs->ipv4_addrs[j].addr);
ipam_insert_ip_for_datapath(od, ip);
ipam_insert_ip_for_datapath(od, ip, false);
}
}

Expand Down Expand Up @@ -1519,7 +1519,7 @@ ipam_add_port_addresses(struct ovn_datapath *od, struct ovn_port *op)
* about a duplicate IP address.
*/
if (ip != op->peer->od->ipam_info.start_ipv4) {
ipam_insert_ip_for_datapath(op->peer->od, ip);
ipam_insert_ip_for_datapath(op->peer->od, ip, false);
}
}
}
Expand Down Expand Up @@ -1744,7 +1744,8 @@ update_unchanged_dynamic_addresses(struct dynamic_address_update *update)
}
if (update->ipv4 == NONE && update->current_addresses.n_ipv4_addrs) {
ipam_insert_ip_for_datapath(update->op->od,
ntohl(update->current_addresses.ipv4_addrs[0].addr));
ntohl(update->current_addresses.ipv4_addrs[0].addr),
true);
}
}

Expand Down Expand Up @@ -1872,7 +1873,7 @@ update_dynamic_addresses(struct dynamic_address_update *update)
ipam_insert_mac(&mac, true);

if (ip4) {
ipam_insert_ip_for_datapath(update->od, ntohl(ip4));
ipam_insert_ip_for_datapath(update->od, ntohl(ip4), true);
ds_put_format(&new_addr, " "IP_FMT, IP_ARGS(ip4));
}
if (!IN6_ARE_ADDR_EQUAL(&ip6, &in6addr_any)) {
Expand Down
2 changes: 1 addition & 1 deletion northd/test-ipam.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ test_ipam_get_unused_ip(struct ovs_cmdl_context *ctx)
uint32_t next_ip = ipam_get_unused_ip(&info);
ds_put_format(&output, IP_FMT "\n", IP_ARGS(htonl(next_ip)));
if (next_ip) {
ovs_assert(ipam_insert_ip(&info, next_ip));
ovs_assert(ipam_insert_ip(&info, next_ip, true));
}
}

Expand Down

0 comments on commit 12886fb

Please sign in to comment.