Skip to content

PD Interface Adjust / LLPD name Of station mode #319

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

Closed
wants to merge 1 commit into from

Conversation

olbjo
Copy link
Collaborator

@olbjo olbjo commented Jan 28, 2021

Add PD Interface Adjust

  • Handle lldp name of station mode
  • Default name of station mode set to standard
  • In lldp replace zero-len station name with mac
  • Update tests

@olbjo olbjo requested a review from pyhys January 28, 2021 15:26
Copy link
Collaborator

@pyhys pyhys left a comment

Choose a reason for hiding this comment

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

Great!
I think we should modify src/common/pf_snmp.c:


void pf_snmp_get_system_description (
   pnet_t * net,
   pf_snmp_system_description_t * description)
{
   (void)pf_lldp_get_system_description (net, description->string, sizeof (description->string));
}

@olbjo olbjo force-pushed the pd_interface_adjust branch 3 times, most recently from b2768cd to 0989fe3 Compare January 29, 2021 13:52
@olbjo olbjo marked this pull request as ready for review January 29, 2021 13:52
Copy link
Collaborator

@pyhys pyhys left a comment

Choose a reason for hiding this comment

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

Great!
Just a few minor comments (I tried to make it copy-paste friendly)

@olbjo olbjo force-pushed the pd_interface_adjust branch from 0989fe3 to 156dbdc Compare February 1, 2021 10:11
@pyhys pyhys changed the title WIP PD Interface Adjust / LLPD name Of station mode PD Interface Adjust / LLPD name Of station mode Feb 1, 2021
@olbjo
Copy link
Collaborator Author

olbjo commented Feb 1, 2021

Some of the suggested updates did not compile. I guess I never saved before local build and test.
Functions using internally. pf_port_get_state() can not have a const net pointer as argument. This applies for some other functions in lldp as well

@olbjo olbjo force-pushed the pd_interface_adjust branch from 156dbdc to aabaaa2 Compare February 1, 2021 12:38
@olbjo olbjo force-pushed the pd_interface_adjust branch 3 times, most recently from 85c3fdf to 2874382 Compare February 2, 2021 12:24
@olbjo
Copy link
Collaborator Author

olbjo commented Feb 2, 2021

Rebased on current to resolve conflicts

Copy link
Collaborator

@fredrikdanielmoller fredrikdanielmoller left a comment

Choose a reason for hiding this comment

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

Reviewed changes for LLDP, pf_port and header files, but not pf_pdport and pf_block_*.

src/pf_types.h Outdated

/**
* LLDP Port Name
* In standard name of device mode this is first part of Port ID
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
* In standard name of device mode this is first part of Port ID
* In standard mode this is first part of Port ID.

Copy link
Collaborator

Choose a reason for hiding this comment

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

name-of-device mode

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I will go with name-of-device mode so it is made clear which mode we are referring to


if (port_id.is_valid)
{
for (i = 0; i < port_id.len && port_id.string[i] != '\0'; i++)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Perhaps use strchr() instead?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I tried but the implementation got a bit messy and I will stick with current version.
I added an additional check of the i-index so that we don't write outside portname if port_id is not correctly formatted. Please check that out.
Done

@olbjo olbjo force-pushed the pd_interface_adjust branch from 2874382 to 6ab4654 Compare February 3, 2021 12:59
if (port_id.is_valid)
{
for (i = 0; (i < port_id.len) && (port_id.string[i] != '\0') &&
(i < (sizeof (p_port_name->string) - 1));
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why was the condition i < (sizeof (p_port_name->string) - 1 introduced?
Given that i < port_id.len, this should always be true

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

port_id.string is 256 characters. I think I risk writing outside port_name->string if the port_id string is not formatted as it should be.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Sorry, I misread it as sizeof (port_id->string) instead of sizeof (p_port_name->string).

- Handle lldp name of station mode
- Default name of station mode set to standard
- In lldp replace zero-len station name with mac
- Update tests
@olbjo olbjo force-pushed the pd_interface_adjust branch from 6ab4654 to 3c470d6 Compare February 3, 2021 16:59
@pyhys pyhys requested a review from hefloryd February 4, 2021 07:42
@olbjo olbjo mentioned this pull request Feb 4, 2021
@olbjo
Copy link
Collaborator Author

olbjo commented Feb 4, 2021

Included in #318 which is now merged.

@olbjo olbjo closed this Feb 4, 2021
@olbjo olbjo deleted the pd_interface_adjust branch May 19, 2021 06:33
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

Successfully merging this pull request may close these issues.

3 participants