Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ospf6d: factor out lsdesc iterator #15725

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 15 additions & 54 deletions ospf6d/ospf6_gr.c
Original file line number Diff line number Diff line change
Expand Up @@ -271,23 +271,13 @@ static int ospf6_router_lsa_contains_adj(struct ospf6_area *area,

type = ntohs(OSPF6_LSTYPE_ROUTER);
for (ALL_LSDB_TYPED_ADVRTR(area->lsdb, type, adv_router, lsa)) {
struct ospf6_router_lsa *router_lsa;
char *start, *end, *current;

struct ospf6_router_lsdesc *lsdesc;
empty = false;
router_lsa = (struct ospf6_router_lsa
*)((char *)lsa->header
+ sizeof(struct ospf6_lsa_header));

/* Iterate over all interfaces in the Router-LSA. */
start = (char *)router_lsa + sizeof(struct ospf6_router_lsa);
end = (char *)lsa->header + ntohs(lsa->header->length);
for (current = start;
current + sizeof(struct ospf6_router_lsdesc) <= end;
current += sizeof(struct ospf6_router_lsdesc)) {
struct ospf6_router_lsdesc *lsdesc;

lsdesc = (struct ospf6_router_lsdesc *)current;
for_each_lsdesc(lsdesc, ospf6_router_lsa, ospf6_router_lsdesc,
lsa)
{
if (lsdesc->type != OSPF6_ROUTER_LSDESC_POINTTOPOINT)
continue;

Expand All @@ -309,22 +299,12 @@ static bool ospf6_gr_check_router_lsa_consistency(struct ospf6 *ospf6,
struct ospf6_lsa *lsa)
{
if (lsa->header->adv_router == ospf6->router_id) {
struct ospf6_router_lsa *router_lsa;
char *start, *end, *current;

router_lsa = (struct ospf6_router_lsa
*)((char *)lsa->header
+ sizeof(struct ospf6_lsa_header));
struct ospf6_router_lsdesc *lsdesc;

/* Iterate over all interfaces in the Router-LSA. */
start = (char *)router_lsa + sizeof(struct ospf6_router_lsa);
end = (char *)lsa->header + ntohs(lsa->header->length);
for (current = start;
current + sizeof(struct ospf6_router_lsdesc) <= end;
current += sizeof(struct ospf6_router_lsdesc)) {
struct ospf6_router_lsdesc *lsdesc;

lsdesc = (struct ospf6_router_lsdesc *)current;
for_each_lsdesc(lsdesc, ospf6_router_lsa, ospf6_router_lsdesc,
lsa)
{
if (lsdesc->type != OSPF6_ROUTER_LSDESC_POINTTOPOINT)
continue;

Expand Down Expand Up @@ -400,8 +380,6 @@ static bool ospf6_gr_check_adjs_lsa_transit(struct ospf6_area *area,
/* Check if we are the DR. */
if (neighbor_router_id == ospf6->router_id) {
struct ospf6_lsa *lsa;
char *start, *end, *current;
struct ospf6_network_lsa *network_lsa;
struct ospf6_network_lsdesc *lsdesc;

/* Lookup Network LSA corresponding to this interface. */
Expand All @@ -412,16 +390,9 @@ static bool ospf6_gr_check_adjs_lsa_transit(struct ospf6_area *area,
return false;

/* Iterate over all routers present in the network. */
network_lsa = (struct ospf6_network_lsa
*)((char *)lsa->header
+ sizeof(struct ospf6_lsa_header));
start = (char *)network_lsa + sizeof(struct ospf6_network_lsa);
end = (char *)lsa->header + ntohs(lsa->header->length);
for (current = start;
current + sizeof(struct ospf6_network_lsdesc) <= end;
current += sizeof(struct ospf6_network_lsdesc)) {
lsdesc = (struct ospf6_network_lsdesc *)current;

for_each_lsdesc(lsdesc, ospf6_network_lsa, ospf6_network_lsdesc,
lsa)
{
/* Skip self in the pseudonode. */
if (lsdesc->router_id == ospf6->router_id)
continue;
Expand Down Expand Up @@ -450,25 +421,15 @@ static bool ospf6_gr_check_adjs_lsa_transit(struct ospf6_area *area,
return true;
}


Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove added whitespace.

static bool ospf6_gr_check_adjs_lsa(struct ospf6_area *area,
struct ospf6_lsa *lsa)
{
struct ospf6_router_lsa *router_lsa;
char *start, *end, *current;

router_lsa =
(struct ospf6_router_lsa *)((char *)lsa->header
+ sizeof(struct ospf6_lsa_header));
struct ospf6_router_lsdesc *lsdesc;

/* Iterate over all interfaces in the Router-LSA. */
start = (char *)router_lsa + sizeof(struct ospf6_router_lsa);
end = (char *)lsa->header + ntohs(lsa->header->length);
for (current = start;
current + sizeof(struct ospf6_router_lsdesc) <= end;
current += sizeof(struct ospf6_router_lsdesc)) {
struct ospf6_router_lsdesc *lsdesc;

lsdesc = (struct ospf6_router_lsdesc *)current;
for_each_lsdesc(lsdesc, ospf6_router_lsa, ospf6_router_lsdesc, lsa)
{
switch (lsdesc->type) {
case OSPF6_ROUTER_LSDESC_POINTTOPOINT:
if (!ospf6_gr_check_adj_id(area,
Expand Down
Loading
Loading