[BGPCEP-695] NPE when next-hop attribute is empty Created: 10/Oct/17  Updated: 20/Jul/21  Resolved: 20/Jul/21

Status: Resolved
Project: bgpcep
Component/s: BGP
Affects Version/s: Bugzilla Migration
Fix Version/s: Sodium

Type: Bug
Reporter: Kevin Wang Assignee: Claudio David Gasparini
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Operating System: All
Platform: All


Attachments: Zip Archive karaf.log.zip    
External issue ID: 9265

 Description   

When the next-hop value is put as empty value in flowspec, a NPE will be thrown.

next-hop attribute is a mandatory attribute in BGP update message. However, it could have zero length in flowspec. ODL is not handling the zero-length case properly.

Related issue:
https://bugs.opendaylight.org/show_bug.cgi?id=5791



 Comments   
Comment by Kevin Wang [ 10/Oct/17 ]

Attachment karaf.log.zip has been added with description: karaf log

Comment by Kevin Wang [ 10/Oct/17 ]

Waiting for review: https://git.opendaylight.org/gerrit/#/c/64129/

Comment by Claudio David Gasparini [ 24/Oct/17 ]

Hi Kevin, this an specific case for flowspec, please add the
reference to the draft/RFC mentioning it to the commit.
Also you should be updating nexhop handlers for flowspec only
https://git.opendaylight.org/gerrit/gitweb?p=bgpcep.git;a=blob;f=bgp/flowspec/src/main/java/org/opendaylight/protocol/bgp/flowspec/BGPActivator.java;h=d15246bc1060e000b6092b389e03855bbe0aa510;hb=refs/heads/master.
>
Also add some test coverage for this case.
>
Regards
Hi Claudio,I think the problem is we should prevent such case from happening
in RESTCONF. If next-hop is required and user submit a RESTCONF
request with empty next-hop, the cohort should return an exception
immediate.Another thing is, we find that if user put <ipv4-next-hop>8.8.8.8</ipv4-next-hop>
in the payload, there is no error to be returned either. However,
<ipv4-next-hop><global>8.8.8.8</global></ipv4-next-hop> is the
correct format.So we need either add a mdsal cohort checking for these sort of
thing (don't think we have such checking in bgp yet), or change the
yang model to make these field mandatory

Comment by Claudio David Gasparini [ 24/Oct/17 ]

Hi Kevin,

  • the patch is abandoned since we agree that is not the correct solution.
  • regarding the issue of pushing ipv4-next-hop against ipv4-next-hop/global, if you consider that it shouldn't work please open a bug for RESTCONF so the issue doesn't get lost.
  • Making the next-hop mandatory in the yang model might be more complicated that it looks, its requires to check where is used the
    updated model and if is correct to be mandatory on all the cases, etc.., anyway when you push the new fix, we can go through it again.

Regards,

Claudio

Comment by Kevin Wang [ 25/Oct/17 ]

Hi cdgasparini,
Do we have any RESTCONF cohort checking in bgp project?
The best solution is to forbid user from injecting empty ipv4-next-hop from restconf. It should be either ipv4-next-hop with a valid IP provided, or the element not appeared at all. An empty element <ipv4-next-hop /> should not be allowed.
If there is such cohort framework exist already in bgp project that I can leverage it will be great.
Or if you have a better solution please let me know.

The fundamental goal is to prevent invalid data from user input. The flowspec handler can only ignore such invalid data without fixing it. When flowspec handler is invoked, it's already at packet serialization stage.

Generated at Wed Feb 07 19:13:51 UTC 2024 using Jira 8.20.10#820010-sha1:ace47f9899e9ee25d7157d59aa17ab06aee30d3d.