Import problem with large AS Sets in 4.8.5

Hagen Boehm hboehm at brutus.NIC.DTAG.DE
Tue Jan 8 09:57:27 UTC 2008


Hi MMC,

this is a bug in the CiscoConfig class in src/RtConfig/f_cisco.cc which I
haven't got around to fix when 4.8.5 was released. Meanwhile I have written
further patches, but they were developed on a slightly different version of
4.8.5 (since we needed more debug output and error reporting in database
communication and also an opportunity to redirect traffic via a web proxy).

Nevertheless the following patch fixes the problem with our version of 4.8.5
and it migth help you to get rid of the problem as well if you carefully
watch the lines. ;-}

I send you the patch attached.

Hope it will help you.


Best regards,


     Hagen Boehm

P.S.: Ouh, there is some problem with mail attachements on this mailing-list,
      isn't it? Okay, patch follows now:

IRRToolSet-4.8.5  patch No. 02

written by: Hagen Boehm

date: Apr 18 2007  15:31

description: when generating an IOS as-path list from an RPSL as-set
description: which contains more than one AS number RtConfig produces
description: incorrect output (e.g. regular expressions with unwanted
description: '@' characters or in case of as-path list definitions
description: with more than 240 characters duplicated regular
description: expressions and corrupted syntax.)
description: Due to string manipulations accidentally done on string
description: copies instead of the original string the bug appears
description: when the original string is used in printing the results.

patched files: src/RtConfig/f_cisco.cc

remarks:

patch:
--- f_cisco.cc.original Tue Jan 23 01:45:16 2007
+++ f_cisco.cc  Wed Apr 18 15:04:16 2007
@@ -734,7 +734,7 @@
                          int aclID, 
                          bool permit){
    ostringstream out;
-    out << "ip as-path access-list "
+   out << "ip as-path access-list "
        << aclID 
        << (permit ? " permit " : " deny ");
    reSplittable = true;
@@ -744,16 +744,15 @@
       out << "_";
    out << endl;
 
-   //int lineLen = strlen(out.str());
    int lineLen = out.str().length();
+   const char *p = out.str().c_str();
+
    if (lineLen < 240 && ! hasTilda) {
-      const char *p = out.str().c_str();
       for (char *q = strchr(p, '@'); q; q = strchr(q, '@'))
         *q = '(';
-      s << out.str();
+      s << p;
    } else { // need to split into multiple lines
       if (hasTilda) {
-        const char *p = out.str().c_str();
         for (char *q = strchr(p, '@'); q; q = strchr(q, '@'))
            *q = '(';
         for (char *q = strchr(p, '&'); q; q = strchr(q, '&'))
@@ -760,25 +759,24 @@
            *q = '@';
       }
 
-      char *p = strdup(out.str().c_str());
-      char *q, *r2;
+      char *q, *q2;
       char *r = NULL;
       int size = 0;
-      for (p = strchr(p, '@'); p; p = strchr(p, '@')) {
-        q = strchr(p, ')');
-        if (q - p > size) {
-           r = p;
-           size = q - p;
+      for (q = strchr(p, '@'); q; q = strchr(q, '@')) {
+        q2 = strchr(q, ')');
+        if (q2 - q > size) {
+           r = q;
+           size = q2 - q;
         }
-        *p = '(';
-        p = q;
+        *q = '(';
+        q = q2;
       }
       if (!r) {
         s << out.str();
         cerr << "Warning: ip as-path access-list is too long for cisco to handle" << endl;
       } else {
+        char *r2;
         int inc = hasTilda ? 1 : (240 - lineLen + size) >? 5;
-        p = strdup(out.str().c_str());
         q = strchr(r, ')') + 1;
         *r = 0;
         r++;



On Tue, Jan 08, 2008 at 12:42:47PM +1030, MMC wrote:
> Hi,
> Okay, one more odd problem with 4.8.5 (apologies for the large email) 
> that I hope someone can help me with.
> 
> If you have a peer with a large AS-SET then the output when it needs to 
> create split lines for as-path access-lists on a Cisco is a bit wierd.
> 
> It looks like this broke first in 4.8.2:
> 
> With a policy of:
> 
> import:         from AS65525 10.1.1.1 at 10.2.2.2
>                   accept <AS-FLAGP>
> 
> For example with 4.8.1 we get the result we'd expect where it's split 
> appropriately:
> 
> # RtConfig -h 203.16.214.210 -p 43 -protocol rawhoisd -config cisco 
> -cisco_use_prefix_lists -supress_martian
> > @RtConfig import ASXXXX 10.2.2.2 AS65525 10.1.1.1
> 
> 4.8.1:
> no ip as-path access-list  1
> ip as-path access-list 1 permit 
> _(112|151|250|702|1140|1200|1290|1830|1836|2009|
> 2018|2042|2129|2277|2561|2571|2609|2612|2687|2697|2706|3092|3095|3225|3291|3300| 
> 
> 3303|3313|3329|3333|3662|3741|3762|3786|3836|3918|4158|4195|4243|4434|4546|4609) 
> 
> _
> ip as-path access-list 1 permit 
> _(4618|4641|4645|4651|4653|4655|4658|4745|4747|4
> 748|4750|4760|4761|4762|4766|4767|4775|4780|4791|4801|4823|4844|5080|5384|5385|5 
> 
> 401|5405|5416|5418|5426|5502|5536|5593|5600|5618|5622|5642|6127|6412|6432|6453)_ 
> 
> ip as-path access-list 1 permit 
> _(6553|6619|6695|6713|6730|6736|6756|6764|6772|6
> 837|6879|6893|6949|7148|7246|7468|7478|7482|7532|7533|7538|7552|7568|7577|7582|7 
> 
> 590|7613|7616|7627|7630|7632|7633|7643|7649|7650|7656|7659|7734|7862|7910|7926)_ 
> 
> 
> (... etc)
> 
> With 4.8.2 and above though we get a result where it looks like it:
> (1) puts an "@" first
> (2) Dumps the whole AS SET
> (3) Then puts the bit which should have only just been there.
> 
> no ip as-path access-list  1
> ip as-path access-list 1 permit 
> _ at 112|151|250|702|1140|1200|1290|1830|1836|2009|
> 2018|2042|2129|2277|2561|2571|2609|2612|2687|2697|2706|3092|3095|3225|3291|3300| 
> 
> 3303|3313|3329|3333|3662|3741|3762|3786|3836|3918|4158|4195|4243|4434|4546|4609| 
> 
> 4618|4641|4645|4651|4653|4655|4658|4745|4747|4748|4750|4760|4761|4762|4766|4767| 
> 
> 4775|4780|4791|4801|4823|4844|5080|5384|5385|5401|5405|5416|5418|5426|5502|5536| 
> 
> 5593|5600|5618|5622|5642|6127|6412|6432|6453|6553|6619|6695|6713|6730|6736|6756| 
> 
> 6764|6772|6837|6879|6893|6949|7148|7246|7468|7478|7482|7532|7533|7538|7552|7568| 
> 
> 7577|7582|7590|7613|7616|7627|7630|7632|7633|7643|7649|7650|7656|7659|7734|7862| 
> 
> 7910|7926|8143|8164|8231|8235|8237|8283|8301|8311|8312|8315|8327|8351|8355|8376| 
> 
> 8379|8408|8452|8495|8520|8524|8529|8564|8640|8659|8665|8703|8729|8781|8802|8803|8805|8820|8821|8883|8893|8895|8918|8934|8935|8953|8954|8960|8961|8966|8978|9007| 
> 
> 9022|9031|9033|9038|9042|9044|9051|9079|9092|9096|9100|9108|9119|9135|9155|9211| 
> 
> 9214|9216|9229|9231|9253|9254|9259|9293|9299|9304|9310|9315|9318|9339|9340|9347| 
> 
> 9396|9411|9415|9416|9420|9430|9440|9472|9475|9484|9486|9502|9520|9526|9528|9533| 
> 
> 9534|9536|9538|9541|9546|9551|9554|9557|9577|9579|9583|9584|9625|9649|9655|9666| 
> 
> 9671|9674|9676|9683|9685|9693|9694|9708|9710|9726|9729|9732|9739|9741|9748|9759| 
> 
> 9765|9784|9823|9829|9830|9831|9833|9835|9836|9873|9875|9879|9881|9891|9910|9918| 
> 
> 9919|9930|9936|9940|9943|9948|9957|9977|9988|9999|10028|10029|10032|10036|10052| 
> 
> 10068|10077|10086|10089|10099|10111|10118|10179|10201|10224|10238|10269|10348|10 
> 
> 530|10586|10852|10879|10999|11300|11331|11367|11908|12127|12128|12143|12323|1234 
> 
> 7|12363|12368|12394|12428|12429|12455|12471|12485|12489|12490|12498|12511|12518| 
> 
> 12523|12524|12546|12586|12614|12620|12623|12649|12650|12651|12652|12654|12660|12 
> 
> 663|12666|12671|12687|12689|12731|12750|12758|12759|12762|12776|12778|12835|1285 
> 
> 4|12871|12880|12902|12907|12913|12923|12928|12974|12977|12989|13003|13007|13012| 
> 
> 13018|13032|13047|13060|13098|13101|13121|13135|13136|13139|13142|13157|13180|13 
> 
> 187|13197|13219|13224|13253|13267|13277|13283|13311|13778|13792|13821|13999|1434 
> 
> 3|14762|15141|15159|15361|15388|15389|15398|15412|15420|15434|15436|15456|15462| 
> 
> 15469|15475|15481|15483|15513|15515|15532|15570|15584|15585|15600|15611|15648|15 
> 
> 649|15650|15651|15660|15661|15663|15675|15715|15722|15767|15772|15795|15796|1579 
> 
> 9|15802|15804|15805|15807|15821|15831|15834|15844|15847|15870|15874|15879|15901| 
> 
> 15904|15933|15946|15978|15981|15986|15998|16004|16011|16029|16031|16072|16079|16 
> 
> 104|16131|16133|16152|16155|16161|16177|16181|16184|16209|16215|16219|16237|1624 
> 
> 3|16248|16267|16281|16298|16313|16318|16322|16327|16350|16353|16378|17350|17398|17408|17414|17416|17422|17423|17425|17427|17433|17439|17443|17444|17451|17453|17 
> 
> 465|17471|17475|17483|17488|17489|17495|17499|17540|17554|17556|17564|17565|1757 
> 
> 0|17575|17590|17606|17624|17625|17634|17639|17666|17669|17709|17710|17724|17726| 
> 
> 17734|17736|17754|17759|17771|17783|17793|17802|17803|17809|17813|17815|17818|17 
> 
> 819|17823|17824|17825|17850|17860|17887|17901|17903|17913|17915|17917|17973|1797 
> 
> 8|17980|17990|18002|18040|18043|18045|18049|18059|18101|18105|18106|18109|18167| 
> 
> 18178|18179|18180|18182|18183|18186|18204|18205|18207|18218|18222|18229|18231|18 
> 
> 234|18253|18302|18356|18386|18391|18399|18403|18408|18410|18411|18413|18415|1841 
> 
> 6|18421|18422|18424|18426|18429|18723|18730|19805|19806|19809|19810|20241|20312| 
> 
> 20484|20493|20501|20504|20526|20532|20586|20598|20599|20612|20634|20642|20653|20 
> 
> 694|20704|20706|20711|20713|20743|20747|20751|20759|20807|20811|20814|20828|2083 
> 
> 5|20847|20854|20857|20858|20859|20867|20868|20893|20914|20915|20918|20928|20940| 
> 
> 20953|20990|21005|21006|21014|21024|21030|21047|21049|21050|21088|21102|21110|21 
> 
> 113|21152|21155|21159|21175|21190|21213|21217|21222|21242|21319|21341|21385|2139 
> 
> 8|21401|21405|21411|21426|21433|21434|21441|21444|21461|21462|21466|21473|21494| 
> 
> 21501|21551|21967|22570|23148|23557|23574|23602|23606|23648|23659|23664|23674|23 
> 
> 678|23685|23687|23693|23709|23712|23725|23740|23749|23750|23768|23772|23837|2385 
> 
> 6|23860|23872|23873|23879|23880|23884|23889|23891|23901|23920|23927|23940|23957| 
> 
> 23966|23976|23978|23984|23995|24000|24002|24009|24020|24028|24036|24040|24055|24 
> 
> 060|24063|24068|24076|24080|24082|24083|24084|24086|24092|24103|24109|24127|2414 
> 
> 2|24157|24158|24160|24161|24213|24214|24216|24217|24218|24222|24236|24237|24239| 
> 
> 24246|24247|24314|24321|24326|24332|24333|24344|24373|24374|24391|24392|24396|24 
> 
> 397|24399|24403|24441|24449|24455|24462|24465|24471|24472|24477|24487|24495|24497|24501|24515|24539|24540|24555|24562|24571|24573|24574|24585|24586|24587|24627| 
> 
> 24629|24631|24632|24634|24637|24642|24692|24731|24736|24747|24753|24780|24781|24 
> 
> 785|24793|24803|24804|24805|24824|24835|24840|24863|24875|24876|24878|24887|2488 
> 
> 9|24904|24908|24910|24940|24952|24953|24957|24977|24994|24996|25019|25020|25059| 
> 
> 25081|25090|25091|25097|25101|25122|25124|25130|25149|25151|25152|25164|25173|25 
> 
> 175|25179|25184|25192|25209|25218|25220|25232|25233|25242|25254|25275|25279|2528 
> 
> 0|25289|25302|25306|25324|25334|25336|25353|25362|25364|25375|25394|25415|25420| 
> 
> 25438|25484|25485|25504|25518|25525|25541|25560|25563|25576|25598|26910|26972|26 
> 
> 976|27281|28686|28687|28710|28749|28767|28788|28791|28805|28823|28857|28866|2887 
> 
> 4|28916|28920|28928|28938|28944|28951|28956|28959|28984|28985|29001|29028|29029| 
> 
> 29043|29051|29058|29068|29073|29077|29079|29094|29121|29126|29140|29157|29158|29 
> 
> 160|29166|29177|29178|29184|29208|29222|29245|29255|29273|29279|29290|29296|2931 
> 
> 1|29356|29357|29374|29378|29380|29383|29384|29390|29404|29411|29428|29430|29435| 
> 
> 29440|29457|29459|29471|29495|29500|29502|29507|29511|29532|29551|29564|29566|29 
> 
> 570|29590|29623|29632|29641|29652|29684|29686|29690|30125|30337|30722|30766|3077 
> 
> 4|30782|30785|30806|30819|30830|30841|30843|30862|30870|30879|30902|30913|30925| 
> 
> 30927|30934|30961|30962|30973|30990|30992|30993|30995|30996|31004|31022|31025|31 
> 
> 030|31033|31051|31052|31064|31065|31076|31078|31086|31095|31097|31126|31141|3114 
> 
> 7|31172|31189|31197|31201|31239|31243|31269|31271|31303|31309|31333|31355|31356| 
> 
> 31361|31400|31416|31424|31452|31467|31476|31488|31508|31530|31544|31545|31549|31 
> 
> 570|31584|31586|31597|31603|31607|31619|31662|31680|31699|31711|31741|32539|3312 
> 
> 8|33517|33727|33777|33778|33782|33785|33788|33789|33792|33799|33803|33833|33845| 
> 
> 33846|33850|33860|33872|33880|33891|33918|33926|33929|33956|33958|33964|33965|33988|34012|34019|34024|34039|34054|34062|34101|34109|34115|34141|34154|34174|3418 
> 
> 1|34193|34210|34225|34249|34261|34286|34288|34305|34309|34345|34369|34370|34396| 
> 
> 34397|34400|34405|34407|34426|34429|34475|34477|34488|34496|34513|34514|34532|34 
> 
> 549|34554|34562|34616|34624|34631|34655|34672|34731|34741|34764|34768|34775|3477 
> 
> 8|34806|34812|34813|34889|34897|34918|34942|34968|34973|35017|35023|35042|35054| 
> 
> 35071|35077|35090|35099|35181|35186|35219|35231|35240|35258|35276|35285|35292|35 
> 
> 316|35321|35329|35332|35343|35388|35396|35458|35460|35467|35470|35471|35501|3553 
> 
> 5|35552|35561|35603|35607|35610|35612|35616|35627|35669|35684|35705|35753|35758| 
> 
> 35782|35814|35821|35829|35946|36057|36415|36870|36885|36893|36906|36929|36935|37 
> 
> 972|37982|37983|37986|37995|37997|38000|38002|38005|38006|38015|38021|38028|3803 
> 
> 4|38044|38058|38072|38098|38104|38105|38108|38110|38111|38112|38113|38130|38139| 
> 
> 38154|38182|38185|38186|38188|38191|38197|38199|38204|38207|38219|38224|38231|38 
> 
> 236|38237|38239|38241|38247|38255|38257|38278|38296|38324|38325|38326|38440|3844 
> 
> 4|38448|38457|38461|38468|38480|38493|38535|38536|38538|38550|38552|38574|38580| 
> 
> 38594|38603|38625|38668|38746|38792|38798|38799|38915|38940|38999|39010|39037|39 
> 
> 059|39074|39123|39132|39136|39145|39166|39200|39217|39221|39227|39228|39236|3924 
> 
> 4|39250|39265|39284|39292|39296|39308|39320|39381|39384|39440|39501|39504|39556| 
> 
> 39598|39616|39624|39637|39640|39641|39681|39682|39704|39729|39750|39854|39867|39 
> 
> 872|39918|39923|40962|40988|40989|40992|41002|41003|41037|41038|41078|41102|4110 
> 
> 8|41126|41132|41138|41144|41152|41163|41172|41173|41176|41252|41264|41286|41294| 
> 
> 41336|41363|41391|41396|41399|41400|41408|41420|41427|41435|41470|41500|41503|41 
> 
> 521|41543|41577|41582|41620|41637|41666|41670|41677|41692|41696|41707|41716|4173 
> 
> 1|41766|41768|41780|41785|41814|41833|41872|41881|41900|41960|42003|42037|42079|42085|42093|42105|42113|42161|42163|42170|42184|42215|42223|42281|42283|42298|42 
> 
> 315|42320|42334|42337|42366|42372|42399|42428|42438|42440|42442|42491|42492|4250 
> 
> 9|42517|42518|42544|42577|42585|42601|42606|42670|42684|42700|42769|42804|42852| 
> 
> 42917|43016|43019|43034)_
> (112|151|250|702|1140|1200|1290|1830|1836|2009|2018|2042|2129|2277|2561|2571|260 
> 
> 9|2612|2687|2697|2706|3092|3095|3225|3291|3300|3303|3313|3329|3333|3662|3741|376 
> 
> 2|3786|3836|3918|4158|4195|4243|4434|4546|4609)_
> 
> ... for thousands of lines repeating similar things.
> 


More information about the irrtoolset mailing list