Skip to content

Commit

Permalink
set the same vlan id on all the locators specified for a particular n…
Browse files Browse the repository at this point in the history
…etworking partition
  • Loading branch information
MarcelJordense committed Oct 9, 2023
1 parent 4a316a9 commit ab1ec36
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 1 deletion.
50 changes: 50 additions & 0 deletions src/core/ddsi/src/ddsi_nwpart.c
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,54 @@ static int check_nwpart_address_consistency (struct ddsi_domaingv *gv)
return nwpart_iter_fini (&npit) ? 0 : -1;
}

static int correct_nwpart_aux_locator (struct ddsi_domaingv *gv)
{
struct nwpart_iter npit;
nwpart_iter_init (&npit, gv);
struct ddsi_config_networkpartition_listelem *np;

if (gv->config.transport_selector != DDSI_TRANS_RAWETH)
return 0;

struct ddsi_tran_factory * const tran = ddsi_factory_find_supported_kind (gv, DDSI_LOCATOR_KIND_RAWETH);
assert (tran != NULL);

while ((np = nwpart_iter_next (&npit)) != NULL)
{
uint32_t loc_aux = 0;

for (struct ddsi_networkpartition_address *a = np->asm_addresses; a && loc_aux == 0; a = a->next)
loc_aux = ddsi_tran_get_locator_aux (tran, &a->loc);
for (struct ddsi_networkpartition_address *a = np->uc_addresses; a && loc_aux == 0; a = a->next)
loc_aux = ddsi_tran_get_locator_aux (tran, &a->loc);
if (loc_aux > 0)
{
uint32_t aux;
for (struct ddsi_networkpartition_address *a = np->asm_addresses; a; a = a->next)
{
if ((aux = ddsi_tran_get_locator_aux (tran, &a->loc)) == 0)
ddsi_tran_set_locator_aux (tran, &a->loc, loc_aux);
else if (aux != loc_aux)
{
nwpart_iter_error (&npit, "", "network partition should use the same vlan id for each address");
break;
}
}
for (struct ddsi_networkpartition_address *a = np->uc_addresses; a; a = a->next)
{
if ((aux = ddsi_tran_get_locator_aux (tran, &a->loc)) == 0)
ddsi_tran_set_locator_aux (tran, &a->loc, loc_aux);
else if (aux != loc_aux)
{
nwpart_iter_error (&npit, "", "network partition should use the same vlan id for each address");
break;
}
}
}
}
return nwpart_iter_fini (&npit) ? 0 : -1;;
}

int ddsi_convert_nwpart_config (struct ddsi_domaingv *gv, uint32_t port_data_uc)
{
int rc;
Expand All @@ -429,6 +477,8 @@ int ddsi_convert_nwpart_config (struct ddsi_domaingv *gv, uint32_t port_data_uc)
return rc;
if ((rc = check_nwpart_address_consistency (gv)) < 0)
return rc;
if ((rc = correct_nwpart_aux_locator (gv)) < 0)
return rc;
return 0;
}

Expand Down
2 changes: 1 addition & 1 deletion src/core/ddsi/src/ddsi_raweth.c
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ static int joinleave_asm_mcgroup (ddsrt_socket_t socket, int join, const ddsi_lo
mreq.mr_ifindex = (int)interf->if_index;
mreq.mr_type = PACKET_MR_MULTICAST;
mreq.mr_alen = 6;
memcpy(mreq.mr_address, mcloc + 10, 6);
memcpy(mreq.mr_address, mcloc->address + 10, 6);
rc = ddsrt_setsockopt(socket, SOL_PACKET, join ? PACKET_ADD_MEMBERSHIP : PACKET_DROP_MEMBERSHIP, &mreq, sizeof(mreq));
return (rc == DDS_RETCODE_OK) ? 0 : rc;
}
Expand Down

0 comments on commit ab1ec36

Please sign in to comment.