[YANGTOOLS-450] v6 prefix checking broken Created: 23/Apr/15  Updated: 10/Apr/22  Resolved: 08/Jun/15

Status: Resolved
Project: yangtools
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug
Reporter: Anton Ivanov Assignee: Tony Tkacik
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Operating System: All
Platform: All


Issue Links:
Blocks
blocks GBP-33 IPv6 some features require PacketIn P... Confirmed
External issue ID: 3051

 Description   

This is an example piece of code from openflowplugin tests.

ActionSetNwSrcReactorTest.java:45

new Ipv6Builder().setIpv6Address(new Ipv6Prefix("1234:5678:9abc:def1:2345:6789:abcd:ef12")).build(),

This passes a prefix without a /X to the Ipv6Prefix constructor.

This should not work. But it does - test passes in stock openflowplugin from helium.



 Comments   
Comment by Tony Tkacik [ 23/Apr/15 ]

remote: https://git.opendaylight.org/gerrit/18922

Comment by Anton Ivanov [ 23/Apr/15 ]

Exec summary: I have no clue what is going on here.

The java code generated by yangtools looks correct. However it accepts input which should definitely fail (as in the openflow example).

The regexps are correct. If I cut-n-paste them into the following perl snippet they work:

#!/usr/bin/perl

@z = ("^((:|[0-9a-fA-F]

{0,4})([0-9a-fA-F]{0,4}

{0,5}

((([0-9a-fA-F]

{0,4}?(:|[0-9a-fA-F]{0,4}

))|(((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])
.)

{3}

(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])))(/(([0-9])|([0-9]

{2}

)|(1[0-1][0-9])|(12[0-8])))\$", "^(([^:]+

{6}

(([^:]:[^:])|(.
..
)))|((([^:][^:])?:([^:][^:])?)(/.+)\$");

while ($a = <STDIN>) {
chomp($a);
foreach $regexp (@z) {
if ($a =~ /$regexp/)

{ print "OK for $regexp\n"; }

else

{ print "NOK for $regexp\n"; }

}
}

Unless there is something in the yang generated code which I have missed, this looks like a bug in the underlying regexp library.

Comment by Carol Sanders [ 19/May/15 ]

Awaiting down stream projects to update their code.
To remain open until new IPv6Builder() is used.

Projects Still failing:
Openflow
OVSDB
GBP

Comment by Anil Vishnoi [ 20/May/15 ]

Hi Carol,

What exactly are the changes that down stream project need to do?

Thanks
Anil

Comment by Anton Ivanov [ 20/May/15 ]

Anil, you need to replace any instantiation of IpvXPrefix (mostly found in Matchers) which is being done without a netmask with a correct argument - with netmask.

The easiest way is utility class with multiple createPrefix() methods:

Ipv6Prefix createPrefix(string);
Ipv6Prefix createPrefix(string, integer);

Ipv6Prefix createPrefix(Ipv6Address);
Ipv6Prefix createPrefix(Ipv6Address, integer);

Ipv4Prefix createPrefix(string);
Ipv4Prefix createPrefix(string, integer);

Ipv4Prefix createPrefix(Ipv4Address);
Ipv4Prefix createPrefix(Ipv4Address, integer);

You just drop that in instead of the direct new IpvXPrefix() instantiation across the board. It will take whatever argument you are feeding it and consume it.

I ended up adding temprorarily (string, string) for openflowplugin, but IMHO that is temporary, the mask has no need of being a string in a network application. Ever.

The easiest way to get that done would have been to override the yangtools generation if we had that facility. As we do not have it, you have to do it manually.

Generated at Wed Feb 07 20:53:17 UTC 2024 using Jira 8.20.10#820010-sha1:ace47f9899e9ee25d7157d59aa17ab06aee30d3d.