Skip to content

Commit

Permalink
IPv4LL: Restart ARP probling on address conflict
Browse files Browse the repository at this point in the history
When IPv4LL address conflict is detected, it is failed to restart IPv4LL
since IPv4LL is running. The commit fixes the problem by restarting ARP
probing instead of restarting IPv4LL.
  • Loading branch information
LeoRuan committed Jul 15, 2024
1 parent fff58e6 commit 776a092
Showing 1 changed file with 23 additions and 6 deletions.
29 changes: 23 additions & 6 deletions src/ipv4ll.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@
#include "sa.h"
#include "script.h"

#ifndef KERNEL_RFC5227
static void ipv4ll_start_arp(void *arg);
#else
static void ipv4ll_start_arp(void *arg) { (void)arg; };
#endif

static const struct in_addr inaddr_llmask = {
.s_addr = HTONL(LINKLOCAL_MASK)
};
Expand Down Expand Up @@ -275,7 +281,7 @@ ipv4ll_found(struct interface *ifp)
eloop_timeout_add_sec(ifp->ctx->eloop,
state->conflicts >= MAX_CONFLICTS ?
RATE_LIMIT_INTERVAL : PROBE_WAIT,
ipv4ll_start, ifp);
ipv4ll_start_arp, ifp);
}

static void
Expand All @@ -290,7 +296,7 @@ ipv4ll_defend_failed(struct interface *ifp)
rt_build(ifp->ctx, AF_INET);
script_runreason(ifp, "IPV4LL");
ipv4ll_pickaddr(ifp);
ipv4ll_start(ifp);
ipv4ll_start_arp(ifp);
}

#ifndef KERNEL_RFC5227
Expand Down Expand Up @@ -323,9 +329,6 @@ ipv4ll_start(void *arg)
struct ipv4ll_state *state;
struct ipv4_addr *ia;
bool repick;
#ifndef KERNEL_RFC5227
struct arp_state *astate;
#endif

if ((state = IPV4LL_STATE(ifp)) == NULL) {
ifp->if_data[IF_DATA_IPV4LL] = calloc(1, sizeof(*state));
Expand Down Expand Up @@ -410,6 +413,20 @@ ipv4ll_start(void *arg)
#ifdef KERNEL_RFC5227
ipv4ll_not_found(ifp);
#else
ipv4ll_start_arp(ifp);
#endif
}

#ifndef KERNEL_RFC5227
static void
ipv4ll_start_arp(void *arg)
{
struct interface *ifp = arg;
struct ipv4ll_state *state;
struct arp_state *astate;

state = IPV4LL_STATE(ifp);

ipv4ll_freearp(ifp);
state->arp = astate = arp_new(ifp, &state->pickedaddr);
if (state->arp == NULL)
Expand All @@ -421,8 +438,8 @@ ipv4ll_start(void *arg)
astate->defend_failed_cb = ipv4ll_defend_failed_arp;
astate->free_cb = ipv4ll_free_arp;
arp_probe(astate);
#endif
}
#endif

void
ipv4ll_drop(struct interface *ifp)
Expand Down

0 comments on commit 776a092

Please sign in to comment.