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

Last Hop Check Issue #131

Closed
wgc1212 opened this issue Nov 15, 2018 · 8 comments
Closed

Last Hop Check Issue #131

wgc1212 opened this issue Nov 15, 2018 · 8 comments

Comments

@wgc1212
Copy link
Contributor

wgc1212 commented Nov 15, 2018

pimd/src/vif.h

Line 82 in 3aefd81

inline static int PIMD_VIFM_LASTHOP_ROUTER(uint8_t *leaves, uint8_t *oifs)

Comparing PIMD_VIFM_LASTHOP_ROUTER() to the released comparison for last hop check:

#define VIFM_LASTHOP_ROUTER(leaves, oifs) ((leaves) & (oifs))

The released software comparison will accept any interface that has both a leave and an oif, while the new comparison requires all interfaces to have both set in order to qualify as a Lasthop router. Is this assessment correct and was this change intentional?

Thanks.

@troglobit
Copy link
Owner

Good catch! No, that change was not intentional. The commit that introduced this was only supposed to change from a uint32_t based bitmask to use a variable length array.

Do you think you could help out with a fix and submit as a pull request?

@wgc1212
Copy link
Contributor Author

wgc1212 commented Nov 15, 2018 via email

@wgc1212
Copy link
Contributor Author

wgc1212 commented Nov 25, 2018

I wasn't sure how updates to the project were supposed to work. Should I enter a pull request for the code first? The routine I was thinking of would be as follows. This would check for any non-zero leaves and oifs in the arrays:

inline static int PIMD_VIFM_LASTHOP_ROUTER(uint8_t *leaves, uint8_t *oifs)
{
    int i=0;
    for (; ((i<MAXVIFS) && (!leaves[i] || !oifs[i])); ++i);
    return((i<MAXVIFS) ? 1 : 0);
}

@troglobit
Copy link
Owner

A pull request is always preferable, they work well also for prototyping code together or getting feedback.

The code looks OK, but I'd like to propose the following instead, which I hope is more readable and yet still correct:

inline static int PIMD_VIFM_LASTHOP_ROUTER(uint8_t *leaves, uint8_t *oifs)
{
    int i;

    for (i = 0; i < MAXVIFS; i++) {
        if (leaves[i] && oifs[i])
            return 1;
    }

    return 0;
}

What do you think?

@wgc1212
Copy link
Contributor Author

wgc1212 commented Nov 26, 2018

That looks fine. I tried to do a pull request, and I didn't seem to be allowed to.

@troglobit
Copy link
Owner

Anybody can do a pull request against pimd. There are no limitations in place. Have you read up on how to do it? https://help.github.com/articles/creating-a-pull-request-from-a-fork/

Briefly, the process is as follows:

  • Fork the repo
  • Create a new branch (with a useful name) in your fork
  • Commit the change to that branch
  • Push change branch to your fork at GitHub
  • Check the GitHub page for your fork, a pull-request button should now appear next to your pushed branch

@wgc1212
Copy link
Contributor Author

wgc1212 commented Nov 27, 2018

Thanks. I have gone through the GitHub process. I had gotten a couple of steps out of order. I have updated the code and have submitted the Pull request.

@troglobit
Copy link
Owner

Good work! Small final comment from me.

wgc1212 added a commit to wgc1212/pimd that referenced this issue Nov 28, 2018
The new v3 pimd uses integer arrays for tracking oifs rather than a bit array in v2.3.2.  The bit array oifs and leaves comparison is a simple C language AND function, which quickly checks for the presence of at least one matching oif or leave.  The new arrays have a little more work to loop through the array comparison.
troglobit added a commit that referenced this issue Nov 28, 2018
Fix #131: Regression in last hop detection
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants