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

bgpd: clear ip bgp instances with safi invalid #1816

Merged
merged 1 commit into from
Mar 7, 2018

Conversation

pguibert6WIND
Copy link
Member

This commit fixes the handling of incoming parameters passed in
following vty functions:

clear ip bgp ipv6 [safi] prefix []
clear ip bgp [vrf ] ipv6 [safi] prefix []

Signed-off-by: Philippe Guibert philippe.guibert@6wind.com

bgpd/bgp_vty.c Outdated
@@ -6413,8 +6413,8 @@ DEFUN (clear_bgp_ipv6_safi_prefix,
"Clear bestpath and re-advertise\n"
"IPv6 prefix\n")
{
int idx_safi = 3;
int idx_ipv6_prefixlen = 5;
int idx_safi = 4;
Copy link
Member

Choose a reason for hiding this comment

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

This is the wrong approach. safi can be 3 or 4. I would recommend searching for the safi string.

Copy link
Member Author

Choose a reason for hiding this comment

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

done

bgpd/bgp_vty.c Outdated
int idx_safi = 3;
int idx_ipv6_prefixlen = 5;
int idx_safi = 4;
int idx_ipv6_prefixlen = 6;
Copy link
Member

Choose a reason for hiding this comment

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

As above, this can be 5 or 6 depending on how the function is called.

bgpd/bgp_vty.c Outdated
int idx_word = 3;
int idx_safi = 5;
int idx_ipv6_prefixlen = 7;
int idx_word = 4;
Copy link
Member

Choose a reason for hiding this comment

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

The same issues exist here and should be fixed in the same manner

@NetDEF-CI
Copy link
Collaborator

Continuous Integration Result: SUCCESSFUL

Congratulations, this patch passed basic tests

Tested-by: NetDEF / OpenSourceRouting.org CI System

CI System Testrun URL: https://ci1.netdef.org/browse/FRR-FRRPULLREQ-2721/

This is a comment from an EXPERIMENTAL automated CI system.
For questions and feedback in regards to this CI system, please feel free to email
Martin Winter - mwinter (at) opensourcerouting.org.


CLANG Static Analyzer Summary

  • Github Pull Request 1816, comparing to Git base SHA c98f4d8

No Changes in Static Analysis warnings compared to base

19 Static Analyzer issues remaining.

See details at
https://ci1.netdef.org/browse/FRR-FRRPULLREQ-2721/artifact/shared/static_analysis/index.html

@pguibert6WIND
Copy link
Member Author

Hi Donald,
I was thinking the vty was rebuilding the whole passed string, so that the argument number is unique.
but ok. I made a new proposal.

@LabN-CI
Copy link
Collaborator

LabN-CI commented Mar 2, 2018

💚 Basic BGPD CI results: SUCCESS, 0 tests failed

Results table
_ _
Result SUCCESS git merge/1816 aa4ed1f
Date 03/02/2018
Start 09:15:16
Finish 09:38:06
Run-Time 22:50
Total 1808
Pass 1808
Fail 0
Valgrind-Errors
Valgrind-Loss
Details vncregress-2018-03-02-09:15:16.txt
Log autoscript-2018-03-02-09:15:59.log.bz2

For details, please contact louberger

@NetDEF-CI
Copy link
Collaborator

Continuous Integration Result: SUCCESSFUL

Congratulations, this patch passed basic tests

Tested-by: NetDEF / OpenSourceRouting.org CI System

CI System Testrun URL: https://ci1.netdef.org/browse/FRR-FRRPULLREQ-2724/

This is a comment from an EXPERIMENTAL automated CI system.
For questions and feedback in regards to this CI system, please feel free to email
Martin Winter - mwinter (at) opensourcerouting.org.


Warnings Generated during build:

Checkout code: Successful with additional warnings:

Report for bgp_vty.c
===============================================
< ERROR: spaces required around that '+=' (ctx:VxV)
< #6460: FILE: /tmp/f1/bgp_vty.c:6460:
< +		idx_ipv6_prefix+=1;
<  		               ^
--
< ERROR: spaces required around that '+=' (ctx:VxV)
< #6490: FILE: /tmp/f1/bgp_vty.c:6490:
< +		idx_ipv6_prefix+=1;
<  		               ^

CLANG Static Analyzer Summary

  • Github Pull Request 1816, comparing to Git base SHA a8e31fc

No Changes in Static Analysis warnings compared to base

19 Static Analyzer issues remaining.

See details at
https://ci1.netdef.org/browse/FRR-FRRPULLREQ-2724/artifact/shared/static_analysis/index.html

@LabN-CI
Copy link
Collaborator

LabN-CI commented Mar 2, 2018

💚 Basic BGPD CI results: SUCCESS, 0 tests failed

Results table
_ _
Result SUCCESS git merge/1816 f07f629
Date 03/02/2018
Start 10:30:15
Finish 10:53:04
Run-Time 22:49
Total 1808
Pass 1808
Fail 0
Valgrind-Errors 0
Valgrind-Loss 0
Details vncregress-2018-03-02-10:30:15.txt
Log autoscript-2018-03-02-10:30:52.log.bz2

For details, please contact louberger

bgpd/bgp_vty.c Outdated
int idx_safi = 5;
int idx_ipv6_prefixlen = 7;
int idx_safi;
int idx_ipv6_prefix = 7;
Copy link
Member

Choose a reason for hiding this comment

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

since you can avoid using indices entirely here, I would do so, as it'll avoid introducing bugs in the future when someone modifies the command and forgets to update the indices...you're already using argv_find() so why not just get rid of the indices entirely?

Copy link
Member Author

Choose a reason for hiding this comment

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

ok

bgpd/bgp_vty.c Outdated

if (argv_find(argv, argc, "view", idx)
|| argv_find(argv, argc, "vrf", idx)) {
vrf_name = argv[*idx + 1]->arg;
Copy link
Member

Choose a reason for hiding this comment

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

this is pointless, you can just do
argv_find(argv, argc, "VIEWVRFNAME", idx)

Copy link
Member Author

Choose a reason for hiding this comment

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

ok

bgpd/bgp_vty.c Outdated

argv_find_and_parse_safi(argv, argc, &idx_safi, &safi);
if (argv_find(argv, argc, "prefix", &idx_ipv6_prefix))
idx_ipv6_prefix += 1;
Copy link
Member

Choose a reason for hiding this comment

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

the whole idea of argv_find (and DEFPY) is to avoid manual index calculations, here you can simply do

int idx = 0;
...
const char *prefix = argv_find(argv, argc, "X:X::X:X/M", &idx) ? argv[idx]->arg : NULL;

Copy link
Member Author

Choose a reason for hiding this comment

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

ok

bgpd/bgp_vty.c Outdated
bgp_vty_find_and_parse_bgp(vty, argv, argc, &idx_word, &bgp);

if (argv_find(argv, argc, "prefix", &idx_ipv6_prefix))
idx_ipv6_prefix += 1;
Copy link
Member

Choose a reason for hiding this comment

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

as before

Copy link
Member Author

Choose a reason for hiding this comment

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

ok

@NetDEF-CI
Copy link
Collaborator

Continuous Integration Result: SUCCESSFUL

Congratulations, this patch passed basic tests

Tested-by: NetDEF / OpenSourceRouting.org CI System

CI System Testrun URL: https://ci1.netdef.org/browse/FRR-FRRPULLREQ-2726/

This is a comment from an EXPERIMENTAL automated CI system.
For questions and feedback in regards to this CI system, please feel free to email
Martin Winter - mwinter (at) opensourcerouting.org.


CLANG Static Analyzer Summary

  • Github Pull Request 1816, comparing to Git base SHA a8e31fc

No Changes in Static Analysis warnings compared to base

19 Static Analyzer issues remaining.

See details at
https://ci1.netdef.org/browse/FRR-FRRPULLREQ-2726/artifact/shared/static_analysis/index.html

@LabN-CI
Copy link
Collaborator

LabN-CI commented Mar 5, 2018

💚 Basic BGPD CI results: SUCCESS, 0 tests failed

Results table
_ _
Result SUCCESS git merge/1816 266e6e4
Date 03/05/2018
Start 03:10:30
Finish 03:33:28
Run-Time 22:58
Total 1813
Pass 1813
Fail 0
Valgrind-Errors 0
Valgrind-Loss 0
Details vncregress-2018-03-05-03:10:30.txt
Log autoscript-2018-03-05-03:11:06.log.bz2

For details, please contact louberger

@NetDEF-CI
Copy link
Collaborator

Continuous Integration Result: SUCCESSFUL

Congratulations, this patch passed basic tests

Tested-by: NetDEF / OpenSourceRouting.org CI System

CI System Testrun URL: https://ci1.netdef.org/browse/FRR-FRRPULLREQ-2732/

This is a comment from an EXPERIMENTAL automated CI system.
For questions and feedback in regards to this CI system, please feel free to email
Martin Winter - mwinter (at) opensourcerouting.org.


CLANG Static Analyzer Summary

  • Github Pull Request 1816, comparing to Git base SHA 6768912

No Changes in Static Analysis warnings compared to base

19 Static Analyzer issues remaining.

See details at
https://ci1.netdef.org/browse/FRR-FRRPULLREQ-2732/artifact/shared/static_analysis/index.html

Copy link
Member

@louberger louberger left a comment

Choose a reason for hiding this comment

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

LGTM

bgpd/bgp_vty.c Outdated
int idx_safi;
int idx_ipv6_prefix;
safi_t safi = SAFI_UNICAST;
char *prefix = argv_find(argv, argc, "X:X::X:X/M", &idx_ipv6_prefix) ?
Copy link
Member

Choose a reason for hiding this comment

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

This is undefined behavior, you need to set idx_ipv6_prefix = 0. You need to do the same for idx_safi.

Copy link
Member Author

Choose a reason for hiding this comment

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

ok

bgpd/bgp_vty.c Outdated
int idx_safi = 5;
int idx_ipv6_prefixlen = 7;
int idx_safi;
int idx_ipv6_prefix;
Copy link
Member

Choose a reason for hiding this comment

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

The same here, both of these need to be set to zero.

Copy link
Member Author

Choose a reason for hiding this comment

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

ok

@LabN-CI
Copy link
Collaborator

LabN-CI commented Mar 7, 2018

💚 Basic BGPD CI results: SUCCESS, 0 tests failed

Results table
_ _
Result SUCCESS git merge/1816 9b475e7
Date 03/07/2018
Start 09:33:09
Finish 09:55:45
Run-Time 22:36
Total 1816
Pass 1816
Fail 0
Valgrind-Errors 0
Valgrind-Loss 0
Details vncregress-2018-03-07-09:33:09.txt
Log autoscript-2018-03-07-09:33:45.log.bz2

For details, please contact louberger

This commit fixes the handling of incoming parameters passed in
following vty functions:

clear ip bgp ipv6 [safi] prefix []
clear ip bgp [vrf ] ipv6 [safi] prefix []

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
@NetDEF-CI
Copy link
Collaborator

Continuous Integration Result: SUCCESSFUL

Congratulations, this patch passed basic tests

Tested-by: NetDEF / OpenSourceRouting.org CI System

CI System Testrun URL: https://ci1.netdef.org/browse/FRR-FRRPULLREQ-2786/

This is a comment from an EXPERIMENTAL automated CI system.
For questions and feedback in regards to this CI system, please feel free to email
Martin Winter - mwinter (at) opensourcerouting.org.


CLANG Static Analyzer Summary

  • Github Pull Request 1816, comparing to Git base SHA 5fe3789

No Changes in Static Analysis warnings compared to base

19 Static Analyzer issues remaining.

See details at
https://ci1.netdef.org/browse/FRR-FRRPULLREQ-2786/artifact/shared/static_analysis/index.html

@qlyoung qlyoung merged commit 8590fba into FRRouting:master Mar 7, 2018
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.

6 participants