bgp_vty.c 369 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707
  1. /* BGP VTY interface.
  2. Copyright (C) 1996, 97, 98, 99, 2000 Kunihiro Ishiguro
  3. This file is part of GNU Zebra.
  4. GNU Zebra is free software; you can redistribute it and/or modify it
  5. under the terms of the GNU General Public License as published by the
  6. Free Software Foundation; either version 2, or (at your option) any
  7. later version.
  8. GNU Zebra is distributed in the hope that it will be useful, but
  9. WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with GNU Zebra; see the file COPYING. If not, write to the Free
  14. Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  15. 02111-1307, USA. */
  16. #include <zebra.h>
  17. #include "command.h"
  18. #include "prefix.h"
  19. #include "plist.h"
  20. #include "buffer.h"
  21. #include "linklist.h"
  22. #include "stream.h"
  23. #include "thread.h"
  24. #include "log.h"
  25. #include "memory.h"
  26. #include "hash.h"
  27. #include "filter.h"
  28. #include "bgpd/bgpd.h"
  29. #include "bgpd/bgp_advertise.h"
  30. #include "bgpd/bgp_attr.h"
  31. #include "bgpd/bgp_aspath.h"
  32. #include "bgpd/bgp_community.h"
  33. #include "bgpd/bgp_ecommunity.h"
  34. #include "bgpd/bgp_damp.h"
  35. #include "bgpd/bgp_debug.h"
  36. #include "bgpd/bgp_fsm.h"
  37. #include "bgpd/bgp_mplsvpn.h"
  38. #include "bgpd/bgp_nexthop.h"
  39. #include "bgpd/bgp_open.h"
  40. #include "bgpd/bgp_regex.h"
  41. #include "bgpd/bgp_route.h"
  42. #include "bgpd/bgp_zebra.h"
  43. #include "bgpd/bgp_table.h"
  44. #include "bgpd/bgp_vty.h"
  45. #include "bgpd/bgp_mpath.h"
  46. extern struct in_addr router_id_zebra;
  47. /* Utility function to get address family from current node. */
  48. afi_t
  49. bgp_node_afi (struct vty *vty)
  50. {
  51. switch (vty->node)
  52. {
  53. case BGP_IPV6_NODE:
  54. case BGP_IPV6M_NODE:
  55. case BGP_VPNV6_NODE:
  56. case BGP_ENCAPV6_NODE:
  57. return AFI_IP6;
  58. break;
  59. }
  60. return AFI_IP;
  61. }
  62. /* Utility function to get subsequent address family from current
  63. node. */
  64. safi_t
  65. bgp_node_safi (struct vty *vty)
  66. {
  67. if (vty->node == BGP_ENCAP_NODE)
  68. return SAFI_ENCAP;
  69. if (vty->node == BGP_ENCAPV6_NODE)
  70. return SAFI_ENCAP;
  71. if (vty->node == BGP_VPNV6_NODE)
  72. return SAFI_MPLS_VPN;
  73. if (vty->node == BGP_VPNV4_NODE)
  74. return SAFI_MPLS_VPN;
  75. if (vty->node == BGP_IPV4M_NODE || vty->node == BGP_IPV6M_NODE)
  76. return SAFI_MULTICAST;
  77. return SAFI_UNICAST;
  78. }
  79. int
  80. bgp_parse_afi(const char *str, afi_t *afi)
  81. {
  82. if (!strcmp(str, "ipv4")) {
  83. *afi = AFI_IP;
  84. return 0;
  85. }
  86. #ifdef HAVE_IPV6
  87. if (!strcmp(str, "ipv6")) {
  88. *afi = AFI_IP6;
  89. return 0;
  90. }
  91. #endif /* HAVE_IPV6 */
  92. return -1;
  93. }
  94. int
  95. bgp_parse_safi(const char *str, safi_t *safi)
  96. {
  97. if (!strcmp(str, "encap")) {
  98. *safi = SAFI_ENCAP;
  99. return 0;
  100. }
  101. if (!strcmp(str, "multicast")) {
  102. *safi = SAFI_MULTICAST;
  103. return 0;
  104. }
  105. if (!strcmp(str, "unicast")) {
  106. *safi = SAFI_UNICAST;
  107. return 0;
  108. }
  109. if (!strcmp(str, "vpn")) {
  110. *safi = SAFI_MPLS_VPN;
  111. return 0;
  112. }
  113. return -1;
  114. }
  115. static int
  116. peer_address_self_check (union sockunion *su)
  117. {
  118. struct interface *ifp = NULL;
  119. if (su->sa.sa_family == AF_INET)
  120. ifp = if_lookup_by_ipv4_exact (&su->sin.sin_addr);
  121. #ifdef HAVE_IPV6
  122. else if (su->sa.sa_family == AF_INET6)
  123. ifp = if_lookup_by_ipv6_exact (&su->sin6.sin6_addr);
  124. #endif /* HAVE IPV6 */
  125. if (ifp)
  126. return 1;
  127. return 0;
  128. }
  129. /* Utility function for looking up peer from VTY. */
  130. static struct peer *
  131. peer_lookup_vty (struct vty *vty, const char *ip_str)
  132. {
  133. int ret;
  134. struct bgp *bgp;
  135. union sockunion su;
  136. struct peer *peer;
  137. bgp = vty->index;
  138. ret = str2sockunion (ip_str, &su);
  139. if (ret < 0)
  140. {
  141. vty_out (vty, "%% Malformed address: %s%s", ip_str, VTY_NEWLINE);
  142. return NULL;
  143. }
  144. peer = peer_lookup (bgp, &su);
  145. if (! peer)
  146. {
  147. vty_out (vty, "%% Specify remote-as or peer-group commands first%s", VTY_NEWLINE);
  148. return NULL;
  149. }
  150. return peer;
  151. }
  152. /* Utility function for looking up peer or peer group. */
  153. static struct peer *
  154. peer_and_group_lookup_vty (struct vty *vty, const char *peer_str)
  155. {
  156. int ret;
  157. struct bgp *bgp;
  158. union sockunion su;
  159. struct peer *peer;
  160. struct peer_group *group;
  161. bgp = vty->index;
  162. ret = str2sockunion (peer_str, &su);
  163. if (ret == 0)
  164. {
  165. peer = peer_lookup (bgp, &su);
  166. if (peer)
  167. return peer;
  168. }
  169. else
  170. {
  171. group = peer_group_lookup (bgp, peer_str);
  172. if (group)
  173. return group->conf;
  174. }
  175. vty_out (vty, "%% Specify remote-as or peer-group commands first%s",
  176. VTY_NEWLINE);
  177. return NULL;
  178. }
  179. static int
  180. bgp_vty_return (struct vty *vty, int ret)
  181. {
  182. const char *str = NULL;
  183. switch (ret)
  184. {
  185. case BGP_ERR_INVALID_VALUE:
  186. str = "Invalid value";
  187. break;
  188. case BGP_ERR_INVALID_FLAG:
  189. str = "Invalid flag";
  190. break;
  191. case BGP_ERR_PEER_INACTIVE:
  192. str = "Activate the neighbor for the address family first";
  193. break;
  194. case BGP_ERR_INVALID_FOR_PEER_GROUP_MEMBER:
  195. str = "Invalid command for a peer-group member";
  196. break;
  197. case BGP_ERR_PEER_GROUP_SHUTDOWN:
  198. str = "Peer-group has been shutdown. Activate the peer-group first";
  199. break;
  200. case BGP_ERR_PEER_GROUP_HAS_THE_FLAG:
  201. str = "This peer is a peer-group member. Please change peer-group configuration";
  202. break;
  203. case BGP_ERR_PEER_FLAG_CONFLICT:
  204. str = "Can't set override-capability and strict-capability-match at the same time";
  205. break;
  206. case BGP_ERR_PEER_GROUP_MEMBER_EXISTS:
  207. str = "No activate for peergroup can be given only if peer-group has no members";
  208. break;
  209. case BGP_ERR_PEER_BELONGS_TO_GROUP:
  210. str = "No activate for an individual peer-group member is invalid";
  211. break;
  212. case BGP_ERR_PEER_GROUP_AF_UNCONFIGURED:
  213. str = "Activate the peer-group for the address family first";
  214. break;
  215. case BGP_ERR_PEER_GROUP_NO_REMOTE_AS:
  216. str = "Specify remote-as or peer-group remote AS first";
  217. break;
  218. case BGP_ERR_PEER_GROUP_CANT_CHANGE:
  219. str = "Cannot change the peer-group. Deconfigure first";
  220. break;
  221. case BGP_ERR_PEER_GROUP_MISMATCH:
  222. str = "Cannot have different peer-group for the neighbor";
  223. break;
  224. case BGP_ERR_PEER_FILTER_CONFLICT:
  225. str = "Prefix/distribute list can not co-exist";
  226. break;
  227. case BGP_ERR_NOT_INTERNAL_PEER:
  228. str = "Invalid command. Not an internal neighbor";
  229. break;
  230. case BGP_ERR_REMOVE_PRIVATE_AS:
  231. str = "Private AS cannot be removed for IBGP peers";
  232. break;
  233. case BGP_ERR_LOCAL_AS_ALLOWED_ONLY_FOR_EBGP:
  234. str = "Local-AS allowed only for EBGP peers";
  235. break;
  236. case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS:
  237. str = "Cannot have local-as same as BGP AS number";
  238. break;
  239. case BGP_ERR_TCPSIG_FAILED:
  240. str = "Error while applying TCP-Sig to session(s)";
  241. break;
  242. case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK:
  243. str = "ebgp-multihop and ttl-security cannot be configured together";
  244. break;
  245. case BGP_ERR_NO_IBGP_WITH_TTLHACK:
  246. str = "ttl-security only allowed for EBGP peers";
  247. break;
  248. }
  249. if (str)
  250. {
  251. vty_out (vty, "%% %s%s", str, VTY_NEWLINE);
  252. return CMD_WARNING;
  253. }
  254. return CMD_SUCCESS;
  255. }
  256. /* BGP global configuration. */
  257. DEFUN (bgp_multiple_instance_func,
  258. bgp_multiple_instance_cmd,
  259. "bgp multiple-instance",
  260. BGP_STR
  261. "Enable bgp multiple instance\n")
  262. {
  263. bgp_option_set (BGP_OPT_MULTIPLE_INSTANCE);
  264. return CMD_SUCCESS;
  265. }
  266. DEFUN (no_bgp_multiple_instance,
  267. no_bgp_multiple_instance_cmd,
  268. "no bgp multiple-instance",
  269. NO_STR
  270. BGP_STR
  271. "BGP multiple instance\n")
  272. {
  273. int ret;
  274. ret = bgp_option_unset (BGP_OPT_MULTIPLE_INSTANCE);
  275. if (ret < 0)
  276. {
  277. vty_out (vty, "%% There are more than two BGP instances%s", VTY_NEWLINE);
  278. return CMD_WARNING;
  279. }
  280. return CMD_SUCCESS;
  281. }
  282. DEFUN (bgp_config_type,
  283. bgp_config_type_cmd,
  284. "bgp config-type (cisco|zebra)",
  285. BGP_STR
  286. "Configuration type\n"
  287. "cisco\n"
  288. "zebra\n")
  289. {
  290. if (strncmp (argv[0], "c", 1) == 0)
  291. bgp_option_set (BGP_OPT_CONFIG_CISCO);
  292. else
  293. bgp_option_unset (BGP_OPT_CONFIG_CISCO);
  294. return CMD_SUCCESS;
  295. }
  296. DEFUN (no_bgp_config_type,
  297. no_bgp_config_type_cmd,
  298. "no bgp config-type",
  299. NO_STR
  300. BGP_STR
  301. "Display configuration type\n")
  302. {
  303. bgp_option_unset (BGP_OPT_CONFIG_CISCO);
  304. return CMD_SUCCESS;
  305. }
  306. DEFUN (no_synchronization,
  307. no_synchronization_cmd,
  308. "no synchronization",
  309. NO_STR
  310. "Perform IGP synchronization\n")
  311. {
  312. return CMD_SUCCESS;
  313. }
  314. DEFUN (no_auto_summary,
  315. no_auto_summary_cmd,
  316. "no auto-summary",
  317. NO_STR
  318. "Enable automatic network number summarization\n")
  319. {
  320. return CMD_SUCCESS;
  321. }
  322. DEFUN_DEPRECATED (neighbor_version,
  323. neighbor_version_cmd,
  324. NEIGHBOR_CMD "version (4|4-)",
  325. NEIGHBOR_STR
  326. NEIGHBOR_ADDR_STR
  327. "Set the BGP version to match a neighbor\n"
  328. "Neighbor's BGP version\n")
  329. {
  330. return CMD_SUCCESS;
  331. }
  332. /* "router bgp" commands. */
  333. DEFUN (router_bgp,
  334. router_bgp_cmd,
  335. "router bgp " CMD_AS_RANGE,
  336. ROUTER_STR
  337. BGP_STR
  338. AS_STR)
  339. {
  340. int ret;
  341. as_t as;
  342. struct bgp *bgp;
  343. const char *name = NULL;
  344. VTY_GET_INTEGER_RANGE ("AS", as, argv[0], 1, BGP_AS4_MAX);
  345. if (argc == 2)
  346. name = argv[1];
  347. ret = bgp_get (&bgp, &as, name);
  348. switch (ret)
  349. {
  350. case BGP_ERR_MULTIPLE_INSTANCE_NOT_SET:
  351. vty_out (vty, "Please specify 'bgp multiple-instance' first%s",
  352. VTY_NEWLINE);
  353. return CMD_WARNING;
  354. case BGP_ERR_AS_MISMATCH:
  355. vty_out (vty, "BGP is already running; AS is %u%s", as, VTY_NEWLINE);
  356. return CMD_WARNING;
  357. case BGP_ERR_INSTANCE_MISMATCH:
  358. vty_out (vty, "BGP view name and AS number mismatch%s", VTY_NEWLINE);
  359. vty_out (vty, "BGP instance is already running; AS is %u%s",
  360. as, VTY_NEWLINE);
  361. return CMD_WARNING;
  362. }
  363. vty->node = BGP_NODE;
  364. vty->index = bgp;
  365. return CMD_SUCCESS;
  366. }
  367. ALIAS (router_bgp,
  368. router_bgp_view_cmd,
  369. "router bgp " CMD_AS_RANGE " view WORD",
  370. ROUTER_STR
  371. BGP_STR
  372. AS_STR
  373. "BGP view\n"
  374. "view name\n")
  375. /* "no router bgp" commands. */
  376. DEFUN (no_router_bgp,
  377. no_router_bgp_cmd,
  378. "no router bgp " CMD_AS_RANGE,
  379. NO_STR
  380. ROUTER_STR
  381. BGP_STR
  382. AS_STR)
  383. {
  384. as_t as;
  385. struct bgp *bgp;
  386. const char *name = NULL;
  387. VTY_GET_INTEGER_RANGE ("AS", as, argv[0], 1, BGP_AS4_MAX);
  388. if (argc == 2)
  389. name = argv[1];
  390. /* Lookup bgp structure. */
  391. bgp = bgp_lookup (as, name);
  392. if (! bgp)
  393. {
  394. vty_out (vty, "%% Can't find BGP instance%s", VTY_NEWLINE);
  395. return CMD_WARNING;
  396. }
  397. bgp_delete (bgp);
  398. return CMD_SUCCESS;
  399. }
  400. ALIAS (no_router_bgp,
  401. no_router_bgp_view_cmd,
  402. "no router bgp " CMD_AS_RANGE " view WORD",
  403. NO_STR
  404. ROUTER_STR
  405. BGP_STR
  406. AS_STR
  407. "BGP view\n"
  408. "view name\n")
  409. /* BGP router-id. */
  410. DEFUN (bgp_router_id,
  411. bgp_router_id_cmd,
  412. "bgp router-id A.B.C.D",
  413. BGP_STR
  414. "Override configured router identifier\n"
  415. "Manually configured router identifier\n")
  416. {
  417. int ret;
  418. struct in_addr id;
  419. struct bgp *bgp;
  420. bgp = vty->index;
  421. ret = inet_aton (argv[0], &id);
  422. if (! ret)
  423. {
  424. vty_out (vty, "%% Malformed bgp router identifier%s", VTY_NEWLINE);
  425. return CMD_WARNING;
  426. }
  427. bgp->router_id_static = id;
  428. bgp_router_id_set (bgp, &id);
  429. return CMD_SUCCESS;
  430. }
  431. DEFUN (no_bgp_router_id,
  432. no_bgp_router_id_cmd,
  433. "no bgp router-id",
  434. NO_STR
  435. BGP_STR
  436. "Override configured router identifier\n")
  437. {
  438. int ret;
  439. struct in_addr id;
  440. struct bgp *bgp;
  441. bgp = vty->index;
  442. if (argc == 1)
  443. {
  444. ret = inet_aton (argv[0], &id);
  445. if (! ret)
  446. {
  447. vty_out (vty, "%% Malformed BGP router identifier%s", VTY_NEWLINE);
  448. return CMD_WARNING;
  449. }
  450. if (! IPV4_ADDR_SAME (&bgp->router_id_static, &id))
  451. {
  452. vty_out (vty, "%% BGP router-id doesn't match%s", VTY_NEWLINE);
  453. return CMD_WARNING;
  454. }
  455. }
  456. bgp->router_id_static.s_addr = 0;
  457. bgp_router_id_set (bgp, &router_id_zebra);
  458. return CMD_SUCCESS;
  459. }
  460. ALIAS (no_bgp_router_id,
  461. no_bgp_router_id_val_cmd,
  462. "no bgp router-id A.B.C.D",
  463. NO_STR
  464. BGP_STR
  465. "Override configured router identifier\n"
  466. "Manually configured router identifier\n")
  467. /* BGP Cluster ID. */
  468. DEFUN (bgp_cluster_id,
  469. bgp_cluster_id_cmd,
  470. "bgp cluster-id A.B.C.D",
  471. BGP_STR
  472. "Configure Route-Reflector Cluster-id\n"
  473. "Route-Reflector Cluster-id in IP address format\n")
  474. {
  475. int ret;
  476. struct bgp *bgp;
  477. struct in_addr cluster;
  478. bgp = vty->index;
  479. ret = inet_aton (argv[0], &cluster);
  480. if (! ret)
  481. {
  482. vty_out (vty, "%% Malformed bgp cluster identifier%s", VTY_NEWLINE);
  483. return CMD_WARNING;
  484. }
  485. bgp_cluster_id_set (bgp, &cluster);
  486. return CMD_SUCCESS;
  487. }
  488. ALIAS (bgp_cluster_id,
  489. bgp_cluster_id32_cmd,
  490. "bgp cluster-id <1-4294967295>",
  491. BGP_STR
  492. "Configure Route-Reflector Cluster-id\n"
  493. "Route-Reflector Cluster-id as 32 bit quantity\n")
  494. DEFUN (no_bgp_cluster_id,
  495. no_bgp_cluster_id_cmd,
  496. "no bgp cluster-id",
  497. NO_STR
  498. BGP_STR
  499. "Configure Route-Reflector Cluster-id\n")
  500. {
  501. int ret;
  502. struct bgp *bgp;
  503. struct in_addr cluster;
  504. bgp = vty->index;
  505. if (argc == 1)
  506. {
  507. ret = inet_aton (argv[0], &cluster);
  508. if (! ret)
  509. {
  510. vty_out (vty, "%% Malformed bgp cluster identifier%s", VTY_NEWLINE);
  511. return CMD_WARNING;
  512. }
  513. }
  514. bgp_cluster_id_unset (bgp);
  515. return CMD_SUCCESS;
  516. }
  517. ALIAS (no_bgp_cluster_id,
  518. no_bgp_cluster_id_arg_cmd,
  519. "no bgp cluster-id A.B.C.D",
  520. NO_STR
  521. BGP_STR
  522. "Configure Route-Reflector Cluster-id\n"
  523. "Route-Reflector Cluster-id in IP address format\n")
  524. DEFUN (bgp_confederation_identifier,
  525. bgp_confederation_identifier_cmd,
  526. "bgp confederation identifier " CMD_AS_RANGE,
  527. "BGP specific commands\n"
  528. "AS confederation parameters\n"
  529. "AS number\n"
  530. "Set routing domain confederation AS\n")
  531. {
  532. struct bgp *bgp;
  533. as_t as;
  534. bgp = vty->index;
  535. VTY_GET_INTEGER_RANGE ("AS", as, argv[0], 1, BGP_AS4_MAX);
  536. bgp_confederation_id_set (bgp, as);
  537. return CMD_SUCCESS;
  538. }
  539. DEFUN (no_bgp_confederation_identifier,
  540. no_bgp_confederation_identifier_cmd,
  541. "no bgp confederation identifier",
  542. NO_STR
  543. "BGP specific commands\n"
  544. "AS confederation parameters\n"
  545. "AS number\n")
  546. {
  547. struct bgp *bgp;
  548. as_t as __attribute__((unused)); /* Dummy for VTY_GET_INTEGER_RANGE */
  549. bgp = vty->index;
  550. if (argc == 1)
  551. VTY_GET_INTEGER_RANGE ("AS", as, argv[0], 1, BGP_AS4_MAX);
  552. bgp_confederation_id_unset (bgp);
  553. return CMD_SUCCESS;
  554. }
  555. ALIAS (no_bgp_confederation_identifier,
  556. no_bgp_confederation_identifier_arg_cmd,
  557. "no bgp confederation identifier " CMD_AS_RANGE,
  558. NO_STR
  559. "BGP specific commands\n"
  560. "AS confederation parameters\n"
  561. "AS number\n"
  562. "Set routing domain confederation AS\n")
  563. DEFUN (bgp_confederation_peers,
  564. bgp_confederation_peers_cmd,
  565. "bgp confederation peers ." CMD_AS_RANGE,
  566. "BGP specific commands\n"
  567. "AS confederation parameters\n"
  568. "Peer ASs in BGP confederation\n"
  569. AS_STR)
  570. {
  571. struct bgp *bgp;
  572. as_t as;
  573. int i;
  574. bgp = vty->index;
  575. for (i = 0; i < argc; i++)
  576. {
  577. VTY_GET_INTEGER_RANGE ("AS", as, argv[i], 1, BGP_AS4_MAX);
  578. if (bgp->as == as)
  579. {
  580. vty_out (vty, "%% Local member-AS not allowed in confed peer list%s",
  581. VTY_NEWLINE);
  582. continue;
  583. }
  584. bgp_confederation_peers_add (bgp, as);
  585. }
  586. return CMD_SUCCESS;
  587. }
  588. DEFUN (no_bgp_confederation_peers,
  589. no_bgp_confederation_peers_cmd,
  590. "no bgp confederation peers ." CMD_AS_RANGE,
  591. NO_STR
  592. "BGP specific commands\n"
  593. "AS confederation parameters\n"
  594. "Peer ASs in BGP confederation\n"
  595. AS_STR)
  596. {
  597. struct bgp *bgp;
  598. as_t as;
  599. int i;
  600. bgp = vty->index;
  601. for (i = 0; i < argc; i++)
  602. {
  603. VTY_GET_INTEGER_RANGE ("AS", as, argv[i], 1, BGP_AS4_MAX);
  604. bgp_confederation_peers_remove (bgp, as);
  605. }
  606. return CMD_SUCCESS;
  607. }
  608. /* Maximum-paths configuration */
  609. DEFUN (bgp_maxpaths,
  610. bgp_maxpaths_cmd,
  611. "maximum-paths <1-255>",
  612. "Forward packets over multiple paths\n"
  613. "Number of paths\n")
  614. {
  615. struct bgp *bgp;
  616. u_int16_t maxpaths;
  617. int ret;
  618. bgp = vty->index;
  619. VTY_GET_INTEGER_RANGE ("maximum-paths", maxpaths, argv[0], 1, 255);
  620. ret = bgp_maximum_paths_set (bgp, bgp_node_afi (vty), bgp_node_safi(vty),
  621. BGP_PEER_EBGP, maxpaths);
  622. if (ret < 0)
  623. {
  624. vty_out (vty,
  625. "%% Failed to set maximum-paths %u for afi %u, safi %u%s",
  626. maxpaths, bgp_node_afi (vty), bgp_node_safi(vty), VTY_NEWLINE);
  627. return CMD_WARNING;
  628. }
  629. if ((MULTIPATH_NUM != 0) && (maxpaths > MULTIPATH_NUM))
  630. vty_out (vty,
  631. "%% Warning: maximum-paths set to %d is greater than %d that zebra is compiled to support%s",
  632. maxpaths, MULTIPATH_NUM, VTY_NEWLINE);
  633. return CMD_SUCCESS;
  634. }
  635. DEFUN (bgp_maxpaths_ibgp,
  636. bgp_maxpaths_ibgp_cmd,
  637. "maximum-paths ibgp <1-255>",
  638. "Forward packets over multiple paths\n"
  639. "iBGP-multipath\n"
  640. "Number of paths\n")
  641. {
  642. struct bgp *bgp;
  643. u_int16_t maxpaths;
  644. int ret;
  645. bgp = vty->index;
  646. VTY_GET_INTEGER_RANGE ("maximum-paths", maxpaths, argv[0], 1, 255);
  647. ret = bgp_maximum_paths_set (bgp, bgp_node_afi (vty), bgp_node_safi(vty),
  648. BGP_PEER_IBGP, maxpaths);
  649. if (ret < 0)
  650. {
  651. vty_out (vty,
  652. "%% Failed to set maximum-paths ibgp %u for afi %u, safi %u%s",
  653. maxpaths, bgp_node_afi (vty), bgp_node_safi(vty), VTY_NEWLINE);
  654. return CMD_WARNING;
  655. }
  656. if ((MULTIPATH_NUM != 0) && (maxpaths > MULTIPATH_NUM))
  657. vty_out (vty,
  658. "%% Warning: maximum-paths set to %d is greater than %d that zebra is compiled to support%s",
  659. maxpaths, MULTIPATH_NUM, VTY_NEWLINE);
  660. return CMD_SUCCESS;
  661. }
  662. DEFUN (no_bgp_maxpaths,
  663. no_bgp_maxpaths_cmd,
  664. "no maximum-paths",
  665. NO_STR
  666. "Forward packets over multiple paths\n"
  667. "Number of paths\n")
  668. {
  669. struct bgp *bgp;
  670. int ret;
  671. bgp = vty->index;
  672. ret = bgp_maximum_paths_unset (bgp, bgp_node_afi (vty), bgp_node_safi(vty),
  673. BGP_PEER_EBGP);
  674. if (ret < 0)
  675. {
  676. vty_out (vty,
  677. "%% Failed to unset maximum-paths for afi %u, safi %u%s",
  678. bgp_node_afi (vty), bgp_node_safi(vty), VTY_NEWLINE);
  679. return CMD_WARNING;
  680. }
  681. return CMD_SUCCESS;
  682. }
  683. ALIAS (no_bgp_maxpaths,
  684. no_bgp_maxpaths_arg_cmd,
  685. "no maximum-paths <1-255>",
  686. NO_STR
  687. "Forward packets over multiple paths\n"
  688. "Number of paths\n")
  689. DEFUN (no_bgp_maxpaths_ibgp,
  690. no_bgp_maxpaths_ibgp_cmd,
  691. "no maximum-paths ibgp",
  692. NO_STR
  693. "Forward packets over multiple paths\n"
  694. "iBGP-multipath\n"
  695. "Number of paths\n")
  696. {
  697. struct bgp *bgp;
  698. int ret;
  699. bgp = vty->index;
  700. ret = bgp_maximum_paths_unset (bgp, bgp_node_afi (vty), bgp_node_safi(vty),
  701. BGP_PEER_IBGP);
  702. if (ret < 0)
  703. {
  704. vty_out (vty,
  705. "%% Failed to unset maximum-paths ibgp for afi %u, safi %u%s",
  706. bgp_node_afi (vty), bgp_node_safi(vty), VTY_NEWLINE);
  707. return CMD_WARNING;
  708. }
  709. return CMD_SUCCESS;
  710. }
  711. ALIAS (no_bgp_maxpaths_ibgp,
  712. no_bgp_maxpaths_ibgp_arg_cmd,
  713. "no maximum-paths ibgp <1-255>",
  714. NO_STR
  715. "Forward packets over multiple paths\n"
  716. "iBGP-multipath\n"
  717. "Number of paths\n")
  718. int
  719. bgp_config_write_maxpaths (struct vty *vty, struct bgp *bgp, afi_t afi,
  720. safi_t safi, int *write)
  721. {
  722. if (bgp->maxpaths[afi][safi].maxpaths_ebgp != BGP_DEFAULT_MAXPATHS)
  723. {
  724. bgp_config_write_family_header (vty, afi, safi, write);
  725. vty_out (vty, " maximum-paths %d%s",
  726. bgp->maxpaths[afi][safi].maxpaths_ebgp, VTY_NEWLINE);
  727. }
  728. if (bgp->maxpaths[afi][safi].maxpaths_ibgp != BGP_DEFAULT_MAXPATHS)
  729. {
  730. bgp_config_write_family_header (vty, afi, safi, write);
  731. vty_out (vty, " maximum-paths ibgp %d%s",
  732. bgp->maxpaths[afi][safi].maxpaths_ibgp, VTY_NEWLINE);
  733. }
  734. return 0;
  735. }
  736. /* BGP timers. */
  737. DEFUN (bgp_timers,
  738. bgp_timers_cmd,
  739. "timers bgp <0-65535> <0-65535>",
  740. "Adjust routing timers\n"
  741. "BGP timers\n"
  742. "Keepalive interval\n"
  743. "Holdtime\n")
  744. {
  745. struct bgp *bgp;
  746. unsigned long keepalive = 0;
  747. unsigned long holdtime = 0;
  748. bgp = vty->index;
  749. VTY_GET_INTEGER ("keepalive", keepalive, argv[0]);
  750. VTY_GET_INTEGER ("holdtime", holdtime, argv[1]);
  751. /* Holdtime value check. */
  752. if (holdtime < 3 && holdtime != 0)
  753. {
  754. vty_out (vty, "%% hold time value must be either 0 or greater than 3%s",
  755. VTY_NEWLINE);
  756. return CMD_WARNING;
  757. }
  758. bgp_timers_set (bgp, keepalive, holdtime);
  759. return CMD_SUCCESS;
  760. }
  761. DEFUN (no_bgp_timers,
  762. no_bgp_timers_cmd,
  763. "no timers bgp",
  764. NO_STR
  765. "Adjust routing timers\n"
  766. "BGP timers\n")
  767. {
  768. struct bgp *bgp;
  769. bgp = vty->index;
  770. bgp_timers_unset (bgp);
  771. return CMD_SUCCESS;
  772. }
  773. ALIAS (no_bgp_timers,
  774. no_bgp_timers_arg_cmd,
  775. "no timers bgp <0-65535> <0-65535>",
  776. NO_STR
  777. "Adjust routing timers\n"
  778. "BGP timers\n"
  779. "Keepalive interval\n"
  780. "Holdtime\n")
  781. DEFUN (bgp_client_to_client_reflection,
  782. bgp_client_to_client_reflection_cmd,
  783. "bgp client-to-client reflection",
  784. "BGP specific commands\n"
  785. "Configure client to client route reflection\n"
  786. "reflection of routes allowed\n")
  787. {
  788. struct bgp *bgp;
  789. bgp = vty->index;
  790. bgp_flag_unset (bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT);
  791. return CMD_SUCCESS;
  792. }
  793. DEFUN (no_bgp_client_to_client_reflection,
  794. no_bgp_client_to_client_reflection_cmd,
  795. "no bgp client-to-client reflection",
  796. NO_STR
  797. "BGP specific commands\n"
  798. "Configure client to client route reflection\n"
  799. "reflection of routes allowed\n")
  800. {
  801. struct bgp *bgp;
  802. bgp = vty->index;
  803. bgp_flag_set (bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT);
  804. return CMD_SUCCESS;
  805. }
  806. /* "bgp always-compare-med" configuration. */
  807. DEFUN (bgp_always_compare_med,
  808. bgp_always_compare_med_cmd,
  809. "bgp always-compare-med",
  810. "BGP specific commands\n"
  811. "Allow comparing MED from different neighbors\n")
  812. {
  813. struct bgp *bgp;
  814. bgp = vty->index;
  815. bgp_flag_set (bgp, BGP_FLAG_ALWAYS_COMPARE_MED);
  816. return CMD_SUCCESS;
  817. }
  818. DEFUN (no_bgp_always_compare_med,
  819. no_bgp_always_compare_med_cmd,
  820. "no bgp always-compare-med",
  821. NO_STR
  822. "BGP specific commands\n"
  823. "Allow comparing MED from different neighbors\n")
  824. {
  825. struct bgp *bgp;
  826. bgp = vty->index;
  827. bgp_flag_unset (bgp, BGP_FLAG_ALWAYS_COMPARE_MED);
  828. return CMD_SUCCESS;
  829. }
  830. /* "bgp deterministic-med" configuration. */
  831. DEFUN (bgp_deterministic_med,
  832. bgp_deterministic_med_cmd,
  833. "bgp deterministic-med",
  834. "BGP specific commands\n"
  835. "Pick the best-MED path among paths advertised from the neighboring AS\n")
  836. {
  837. struct bgp *bgp;
  838. bgp = vty->index;
  839. bgp_flag_set (bgp, BGP_FLAG_DETERMINISTIC_MED);
  840. return CMD_SUCCESS;
  841. }
  842. DEFUN (no_bgp_deterministic_med,
  843. no_bgp_deterministic_med_cmd,
  844. "no bgp deterministic-med",
  845. NO_STR
  846. "BGP specific commands\n"
  847. "Pick the best-MED path among paths advertised from the neighboring AS\n")
  848. {
  849. struct bgp *bgp;
  850. bgp = vty->index;
  851. bgp_flag_unset (bgp, BGP_FLAG_DETERMINISTIC_MED);
  852. return CMD_SUCCESS;
  853. }
  854. /* "bgp graceful-restart" configuration. */
  855. DEFUN (bgp_graceful_restart,
  856. bgp_graceful_restart_cmd,
  857. "bgp graceful-restart",
  858. "BGP specific commands\n"
  859. "Graceful restart capability parameters\n")
  860. {
  861. struct bgp *bgp;
  862. bgp = vty->index;
  863. bgp_flag_set (bgp, BGP_FLAG_GRACEFUL_RESTART);
  864. return CMD_SUCCESS;
  865. }
  866. DEFUN (no_bgp_graceful_restart,
  867. no_bgp_graceful_restart_cmd,
  868. "no bgp graceful-restart",
  869. NO_STR
  870. "BGP specific commands\n"
  871. "Graceful restart capability parameters\n")
  872. {
  873. struct bgp *bgp;
  874. bgp = vty->index;
  875. bgp_flag_unset (bgp, BGP_FLAG_GRACEFUL_RESTART);
  876. return CMD_SUCCESS;
  877. }
  878. DEFUN (bgp_graceful_restart_stalepath_time,
  879. bgp_graceful_restart_stalepath_time_cmd,
  880. "bgp graceful-restart stalepath-time <1-3600>",
  881. "BGP specific commands\n"
  882. "Graceful restart capability parameters\n"
  883. "Set the max time to hold onto restarting peer's stale paths\n"
  884. "Delay value (seconds)\n")
  885. {
  886. struct bgp *bgp;
  887. u_int32_t stalepath;
  888. bgp = vty->index;
  889. if (! bgp)
  890. return CMD_WARNING;
  891. VTY_GET_INTEGER_RANGE ("stalepath-time", stalepath, argv[0], 1, 3600);
  892. bgp->stalepath_time = stalepath;
  893. return CMD_SUCCESS;
  894. }
  895. DEFUN (no_bgp_graceful_restart_stalepath_time,
  896. no_bgp_graceful_restart_stalepath_time_cmd,
  897. "no bgp graceful-restart stalepath-time",
  898. NO_STR
  899. "BGP specific commands\n"
  900. "Graceful restart capability parameters\n"
  901. "Set the max time to hold onto restarting peer's stale paths\n")
  902. {
  903. struct bgp *bgp;
  904. bgp = vty->index;
  905. if (! bgp)
  906. return CMD_WARNING;
  907. bgp->stalepath_time = BGP_DEFAULT_STALEPATH_TIME;
  908. return CMD_SUCCESS;
  909. }
  910. ALIAS (no_bgp_graceful_restart_stalepath_time,
  911. no_bgp_graceful_restart_stalepath_time_val_cmd,
  912. "no bgp graceful-restart stalepath-time <1-3600>",
  913. NO_STR
  914. "BGP specific commands\n"
  915. "Graceful restart capability parameters\n"
  916. "Set the max time to hold onto restarting peer's stale paths\n"
  917. "Delay value (seconds)\n")
  918. /* "bgp fast-external-failover" configuration. */
  919. DEFUN (bgp_fast_external_failover,
  920. bgp_fast_external_failover_cmd,
  921. "bgp fast-external-failover",
  922. BGP_STR
  923. "Immediately reset session if a link to a directly connected external peer goes down\n")
  924. {
  925. struct bgp *bgp;
  926. bgp = vty->index;
  927. bgp_flag_unset (bgp, BGP_FLAG_NO_FAST_EXT_FAILOVER);
  928. return CMD_SUCCESS;
  929. }
  930. DEFUN (no_bgp_fast_external_failover,
  931. no_bgp_fast_external_failover_cmd,
  932. "no bgp fast-external-failover",
  933. NO_STR
  934. BGP_STR
  935. "Immediately reset session if a link to a directly connected external peer goes down\n")
  936. {
  937. struct bgp *bgp;
  938. bgp = vty->index;
  939. bgp_flag_set (bgp, BGP_FLAG_NO_FAST_EXT_FAILOVER);
  940. return CMD_SUCCESS;
  941. }
  942. /* "bgp enforce-first-as" configuration. */
  943. DEFUN (bgp_enforce_first_as,
  944. bgp_enforce_first_as_cmd,
  945. "bgp enforce-first-as",
  946. BGP_STR
  947. "Enforce the first AS for EBGP routes\n")
  948. {
  949. struct bgp *bgp;
  950. bgp = vty->index;
  951. bgp_flag_set (bgp, BGP_FLAG_ENFORCE_FIRST_AS);
  952. return CMD_SUCCESS;
  953. }
  954. DEFUN (no_bgp_enforce_first_as,
  955. no_bgp_enforce_first_as_cmd,
  956. "no bgp enforce-first-as",
  957. NO_STR
  958. BGP_STR
  959. "Enforce the first AS for EBGP routes\n")
  960. {
  961. struct bgp *bgp;
  962. bgp = vty->index;
  963. bgp_flag_unset (bgp, BGP_FLAG_ENFORCE_FIRST_AS);
  964. return CMD_SUCCESS;
  965. }
  966. /* "bgp bestpath compare-routerid" configuration. */
  967. DEFUN (bgp_bestpath_compare_router_id,
  968. bgp_bestpath_compare_router_id_cmd,
  969. "bgp bestpath compare-routerid",
  970. "BGP specific commands\n"
  971. "Change the default bestpath selection\n"
  972. "Compare router-id for identical EBGP paths\n")
  973. {
  974. struct bgp *bgp;
  975. bgp = vty->index;
  976. bgp_flag_set (bgp, BGP_FLAG_COMPARE_ROUTER_ID);
  977. return CMD_SUCCESS;
  978. }
  979. DEFUN (no_bgp_bestpath_compare_router_id,
  980. no_bgp_bestpath_compare_router_id_cmd,
  981. "no bgp bestpath compare-routerid",
  982. NO_STR
  983. "BGP specific commands\n"
  984. "Change the default bestpath selection\n"
  985. "Compare router-id for identical EBGP paths\n")
  986. {
  987. struct bgp *bgp;
  988. bgp = vty->index;
  989. bgp_flag_unset (bgp, BGP_FLAG_COMPARE_ROUTER_ID);
  990. return CMD_SUCCESS;
  991. }
  992. /* "bgp bestpath as-path ignore" configuration. */
  993. DEFUN (bgp_bestpath_aspath_ignore,
  994. bgp_bestpath_aspath_ignore_cmd,
  995. "bgp bestpath as-path ignore",
  996. "BGP specific commands\n"
  997. "Change the default bestpath selection\n"
  998. "AS-path attribute\n"
  999. "Ignore as-path length in selecting a route\n")
  1000. {
  1001. struct bgp *bgp;
  1002. bgp = vty->index;
  1003. bgp_flag_set (bgp, BGP_FLAG_ASPATH_IGNORE);
  1004. return CMD_SUCCESS;
  1005. }
  1006. DEFUN (no_bgp_bestpath_aspath_ignore,
  1007. no_bgp_bestpath_aspath_ignore_cmd,
  1008. "no bgp bestpath as-path ignore",
  1009. NO_STR
  1010. "BGP specific commands\n"
  1011. "Change the default bestpath selection\n"
  1012. "AS-path attribute\n"
  1013. "Ignore as-path length in selecting a route\n")
  1014. {
  1015. struct bgp *bgp;
  1016. bgp = vty->index;
  1017. bgp_flag_unset (bgp, BGP_FLAG_ASPATH_IGNORE);
  1018. return CMD_SUCCESS;
  1019. }
  1020. /* "bgp bestpath as-path confed" configuration. */
  1021. DEFUN (bgp_bestpath_aspath_confed,
  1022. bgp_bestpath_aspath_confed_cmd,
  1023. "bgp bestpath as-path confed",
  1024. "BGP specific commands\n"
  1025. "Change the default bestpath selection\n"
  1026. "AS-path attribute\n"
  1027. "Compare path lengths including confederation sets & sequences in selecting a route\n")
  1028. {
  1029. struct bgp *bgp;
  1030. bgp = vty->index;
  1031. bgp_flag_set (bgp, BGP_FLAG_ASPATH_CONFED);
  1032. return CMD_SUCCESS;
  1033. }
  1034. DEFUN (no_bgp_bestpath_aspath_confed,
  1035. no_bgp_bestpath_aspath_confed_cmd,
  1036. "no bgp bestpath as-path confed",
  1037. NO_STR
  1038. "BGP specific commands\n"
  1039. "Change the default bestpath selection\n"
  1040. "AS-path attribute\n"
  1041. "Compare path lengths including confederation sets & sequences in selecting a route\n")
  1042. {
  1043. struct bgp *bgp;
  1044. bgp = vty->index;
  1045. bgp_flag_unset (bgp, BGP_FLAG_ASPATH_CONFED);
  1046. return CMD_SUCCESS;
  1047. }
  1048. /* "bgp bestpath as-path multipath-relax" configuration. */
  1049. DEFUN (bgp_bestpath_aspath_multipath_relax,
  1050. bgp_bestpath_aspath_multipath_relax_cmd,
  1051. "bgp bestpath as-path multipath-relax",
  1052. "BGP specific commands\n"
  1053. "Change the default bestpath selection\n"
  1054. "AS-path attribute\n"
  1055. "Allow load sharing across routes that have different AS paths (but same length)\n")
  1056. {
  1057. struct bgp *bgp;
  1058. bgp = vty->index;
  1059. bgp_flag_set (bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX);
  1060. return CMD_SUCCESS;
  1061. }
  1062. DEFUN (no_bgp_bestpath_aspath_multipath_relax,
  1063. no_bgp_bestpath_aspath_multipath_relax_cmd,
  1064. "no bgp bestpath as-path multipath-relax",
  1065. NO_STR
  1066. "BGP specific commands\n"
  1067. "Change the default bestpath selection\n"
  1068. "AS-path attribute\n"
  1069. "Allow load sharing across routes that have different AS paths (but same length)\n")
  1070. {
  1071. struct bgp *bgp;
  1072. bgp = vty->index;
  1073. bgp_flag_unset (bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX);
  1074. return CMD_SUCCESS;
  1075. }
  1076. /* "bgp log-neighbor-changes" configuration. */
  1077. DEFUN (bgp_log_neighbor_changes,
  1078. bgp_log_neighbor_changes_cmd,
  1079. "bgp log-neighbor-changes",
  1080. "BGP specific commands\n"
  1081. "Log neighbor up/down and reset reason\n")
  1082. {
  1083. struct bgp *bgp;
  1084. bgp = vty->index;
  1085. bgp_flag_set (bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES);
  1086. return CMD_SUCCESS;
  1087. }
  1088. DEFUN (no_bgp_log_neighbor_changes,
  1089. no_bgp_log_neighbor_changes_cmd,
  1090. "no bgp log-neighbor-changes",
  1091. NO_STR
  1092. "BGP specific commands\n"
  1093. "Log neighbor up/down and reset reason\n")
  1094. {
  1095. struct bgp *bgp;
  1096. bgp = vty->index;
  1097. bgp_flag_unset (bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES);
  1098. return CMD_SUCCESS;
  1099. }
  1100. /* "bgp bestpath med" configuration. */
  1101. DEFUN (bgp_bestpath_med,
  1102. bgp_bestpath_med_cmd,
  1103. "bgp bestpath med (confed|missing-as-worst)",
  1104. "BGP specific commands\n"
  1105. "Change the default bestpath selection\n"
  1106. "MED attribute\n"
  1107. "Compare MED among confederation paths\n"
  1108. "Treat missing MED as the least preferred one\n")
  1109. {
  1110. struct bgp *bgp;
  1111. bgp = vty->index;
  1112. if (strncmp (argv[0], "confed", 1) == 0)
  1113. bgp_flag_set (bgp, BGP_FLAG_MED_CONFED);
  1114. else
  1115. bgp_flag_set (bgp, BGP_FLAG_MED_MISSING_AS_WORST);
  1116. return CMD_SUCCESS;
  1117. }
  1118. DEFUN (bgp_bestpath_med2,
  1119. bgp_bestpath_med2_cmd,
  1120. "bgp bestpath med confed missing-as-worst",
  1121. "BGP specific commands\n"
  1122. "Change the default bestpath selection\n"
  1123. "MED attribute\n"
  1124. "Compare MED among confederation paths\n"
  1125. "Treat missing MED as the least preferred one\n")
  1126. {
  1127. struct bgp *bgp;
  1128. bgp = vty->index;
  1129. bgp_flag_set (bgp, BGP_FLAG_MED_CONFED);
  1130. bgp_flag_set (bgp, BGP_FLAG_MED_MISSING_AS_WORST);
  1131. return CMD_SUCCESS;
  1132. }
  1133. ALIAS (bgp_bestpath_med2,
  1134. bgp_bestpath_med3_cmd,
  1135. "bgp bestpath med missing-as-worst confed",
  1136. "BGP specific commands\n"
  1137. "Change the default bestpath selection\n"
  1138. "MED attribute\n"
  1139. "Treat missing MED as the least preferred one\n"
  1140. "Compare MED among confederation paths\n")
  1141. DEFUN (no_bgp_bestpath_med,
  1142. no_bgp_bestpath_med_cmd,
  1143. "no bgp bestpath med (confed|missing-as-worst)",
  1144. NO_STR
  1145. "BGP specific commands\n"
  1146. "Change the default bestpath selection\n"
  1147. "MED attribute\n"
  1148. "Compare MED among confederation paths\n"
  1149. "Treat missing MED as the least preferred one\n")
  1150. {
  1151. struct bgp *bgp;
  1152. bgp = vty->index;
  1153. if (strncmp (argv[0], "confed", 1) == 0)
  1154. bgp_flag_unset (bgp, BGP_FLAG_MED_CONFED);
  1155. else
  1156. bgp_flag_unset (bgp, BGP_FLAG_MED_MISSING_AS_WORST);
  1157. return CMD_SUCCESS;
  1158. }
  1159. DEFUN (no_bgp_bestpath_med2,
  1160. no_bgp_bestpath_med2_cmd,
  1161. "no bgp bestpath med confed missing-as-worst",
  1162. NO_STR
  1163. "BGP specific commands\n"
  1164. "Change the default bestpath selection\n"
  1165. "MED attribute\n"
  1166. "Compare MED among confederation paths\n"
  1167. "Treat missing MED as the least preferred one\n")
  1168. {
  1169. struct bgp *bgp;
  1170. bgp = vty->index;
  1171. bgp_flag_unset (bgp, BGP_FLAG_MED_CONFED);
  1172. bgp_flag_unset (bgp, BGP_FLAG_MED_MISSING_AS_WORST);
  1173. return CMD_SUCCESS;
  1174. }
  1175. ALIAS (no_bgp_bestpath_med2,
  1176. no_bgp_bestpath_med3_cmd,
  1177. "no bgp bestpath med missing-as-worst confed",
  1178. NO_STR
  1179. "BGP specific commands\n"
  1180. "Change the default bestpath selection\n"
  1181. "MED attribute\n"
  1182. "Treat missing MED as the least preferred one\n"
  1183. "Compare MED among confederation paths\n")
  1184. /* "no bgp default ipv4-unicast". */
  1185. DEFUN (no_bgp_default_ipv4_unicast,
  1186. no_bgp_default_ipv4_unicast_cmd,
  1187. "no bgp default ipv4-unicast",
  1188. NO_STR
  1189. "BGP specific commands\n"
  1190. "Configure BGP defaults\n"
  1191. "Activate ipv4-unicast for a peer by default\n")
  1192. {
  1193. struct bgp *bgp;
  1194. bgp = vty->index;
  1195. bgp_flag_set (bgp, BGP_FLAG_NO_DEFAULT_IPV4);
  1196. return CMD_SUCCESS;
  1197. }
  1198. DEFUN (bgp_default_ipv4_unicast,
  1199. bgp_default_ipv4_unicast_cmd,
  1200. "bgp default ipv4-unicast",
  1201. "BGP specific commands\n"
  1202. "Configure BGP defaults\n"
  1203. "Activate ipv4-unicast for a peer by default\n")
  1204. {
  1205. struct bgp *bgp;
  1206. bgp = vty->index;
  1207. bgp_flag_unset (bgp, BGP_FLAG_NO_DEFAULT_IPV4);
  1208. return CMD_SUCCESS;
  1209. }
  1210. /* "bgp import-check" configuration. */
  1211. DEFUN (bgp_network_import_check,
  1212. bgp_network_import_check_cmd,
  1213. "bgp network import-check",
  1214. "BGP specific commands\n"
  1215. "BGP network command\n"
  1216. "Check BGP network route exists in IGP\n")
  1217. {
  1218. struct bgp *bgp;
  1219. bgp = vty->index;
  1220. bgp_flag_set (bgp, BGP_FLAG_IMPORT_CHECK);
  1221. return CMD_SUCCESS;
  1222. }
  1223. DEFUN (no_bgp_network_import_check,
  1224. no_bgp_network_import_check_cmd,
  1225. "no bgp network import-check",
  1226. NO_STR
  1227. "BGP specific commands\n"
  1228. "BGP network command\n"
  1229. "Check BGP network route exists in IGP\n")
  1230. {
  1231. struct bgp *bgp;
  1232. bgp = vty->index;
  1233. bgp_flag_unset (bgp, BGP_FLAG_IMPORT_CHECK);
  1234. return CMD_SUCCESS;
  1235. }
  1236. DEFUN (bgp_default_local_preference,
  1237. bgp_default_local_preference_cmd,
  1238. "bgp default local-preference <0-4294967295>",
  1239. "BGP specific commands\n"
  1240. "Configure BGP defaults\n"
  1241. "local preference (higher=more preferred)\n"
  1242. "Configure default local preference value\n")
  1243. {
  1244. struct bgp *bgp;
  1245. u_int32_t local_pref;
  1246. bgp = vty->index;
  1247. VTY_GET_INTEGER ("local preference", local_pref, argv[0]);
  1248. bgp_default_local_preference_set (bgp, local_pref);
  1249. return CMD_SUCCESS;
  1250. }
  1251. DEFUN (no_bgp_default_local_preference,
  1252. no_bgp_default_local_preference_cmd,
  1253. "no bgp default local-preference",
  1254. NO_STR
  1255. "BGP specific commands\n"
  1256. "Configure BGP defaults\n"
  1257. "local preference (higher=more preferred)\n")
  1258. {
  1259. struct bgp *bgp;
  1260. bgp = vty->index;
  1261. bgp_default_local_preference_unset (bgp);
  1262. return CMD_SUCCESS;
  1263. }
  1264. ALIAS (no_bgp_default_local_preference,
  1265. no_bgp_default_local_preference_val_cmd,
  1266. "no bgp default local-preference <0-4294967295>",
  1267. NO_STR
  1268. "BGP specific commands\n"
  1269. "Configure BGP defaults\n"
  1270. "local preference (higher=more preferred)\n"
  1271. "Configure default local preference value\n")
  1272. static int
  1273. peer_remote_as_vty (struct vty *vty, const char *peer_str,
  1274. const char *as_str, afi_t afi, safi_t safi)
  1275. {
  1276. int ret;
  1277. struct bgp *bgp;
  1278. as_t as;
  1279. union sockunion su;
  1280. bgp = vty->index;
  1281. /* Get AS number. */
  1282. VTY_GET_INTEGER_RANGE ("AS", as, as_str, 1, BGP_AS4_MAX);
  1283. /* If peer is peer group, call proper function. */
  1284. ret = str2sockunion (peer_str, &su);
  1285. if (ret < 0)
  1286. {
  1287. ret = peer_group_remote_as (bgp, peer_str, &as);
  1288. if (ret < 0)
  1289. {
  1290. vty_out (vty, "%% Create the peer-group first%s", VTY_NEWLINE);
  1291. return CMD_WARNING;
  1292. }
  1293. return CMD_SUCCESS;
  1294. }
  1295. if (peer_address_self_check (&su))
  1296. {
  1297. vty_out (vty, "%% Can not configure the local system as neighbor%s",
  1298. VTY_NEWLINE);
  1299. return CMD_WARNING;
  1300. }
  1301. ret = peer_remote_as (bgp, &su, &as, afi, safi);
  1302. /* This peer belongs to peer group. */
  1303. switch (ret)
  1304. {
  1305. case BGP_ERR_PEER_GROUP_MEMBER:
  1306. vty_out (vty, "%% Peer-group AS %u. Cannot configure remote-as for member%s", as, VTY_NEWLINE);
  1307. return CMD_WARNING;
  1308. case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT:
  1309. vty_out (vty, "%% The AS# can not be changed from %u to %s, peer-group members must be all internal or all external%s", as, as_str, VTY_NEWLINE);
  1310. return CMD_WARNING;
  1311. }
  1312. return bgp_vty_return (vty, ret);
  1313. }
  1314. DEFUN (neighbor_remote_as,
  1315. neighbor_remote_as_cmd,
  1316. NEIGHBOR_CMD2 "remote-as " CMD_AS_RANGE,
  1317. NEIGHBOR_STR
  1318. NEIGHBOR_ADDR_STR2
  1319. "Specify a BGP neighbor\n"
  1320. AS_STR)
  1321. {
  1322. return peer_remote_as_vty (vty, argv[0], argv[1], AFI_IP, SAFI_UNICAST);
  1323. }
  1324. DEFUN (neighbor_peer_group,
  1325. neighbor_peer_group_cmd,
  1326. "neighbor WORD peer-group",
  1327. NEIGHBOR_STR
  1328. "Neighbor tag\n"
  1329. "Configure peer-group\n")
  1330. {
  1331. struct bgp *bgp;
  1332. struct peer_group *group;
  1333. bgp = vty->index;
  1334. group = peer_group_get (bgp, argv[0]);
  1335. if (! group)
  1336. return CMD_WARNING;
  1337. return CMD_SUCCESS;
  1338. }
  1339. DEFUN (no_neighbor,
  1340. no_neighbor_cmd,
  1341. NO_NEIGHBOR_CMD2,
  1342. NO_STR
  1343. NEIGHBOR_STR
  1344. NEIGHBOR_ADDR_STR2)
  1345. {
  1346. int ret;
  1347. union sockunion su;
  1348. struct peer_group *group;
  1349. struct peer *peer;
  1350. ret = str2sockunion (argv[0], &su);
  1351. if (ret < 0)
  1352. {
  1353. group = peer_group_lookup (vty->index, argv[0]);
  1354. if (group)
  1355. peer_group_delete (group);
  1356. else
  1357. {
  1358. vty_out (vty, "%% Create the peer-group first%s", VTY_NEWLINE);
  1359. return CMD_WARNING;
  1360. }
  1361. }
  1362. else
  1363. {
  1364. peer = peer_lookup (vty->index, &su);
  1365. if (peer)
  1366. peer_delete (peer);
  1367. }
  1368. return CMD_SUCCESS;
  1369. }
  1370. ALIAS (no_neighbor,
  1371. no_neighbor_remote_as_cmd,
  1372. NO_NEIGHBOR_CMD "remote-as " CMD_AS_RANGE,
  1373. NO_STR
  1374. NEIGHBOR_STR
  1375. NEIGHBOR_ADDR_STR
  1376. "Specify a BGP neighbor\n"
  1377. AS_STR)
  1378. DEFUN (no_neighbor_peer_group,
  1379. no_neighbor_peer_group_cmd,
  1380. "no neighbor WORD peer-group",
  1381. NO_STR
  1382. NEIGHBOR_STR
  1383. "Neighbor tag\n"
  1384. "Configure peer-group\n")
  1385. {
  1386. struct peer_group *group;
  1387. group = peer_group_lookup (vty->index, argv[0]);
  1388. if (group)
  1389. peer_group_delete (group);
  1390. else
  1391. {
  1392. vty_out (vty, "%% Create the peer-group first%s", VTY_NEWLINE);
  1393. return CMD_WARNING;
  1394. }
  1395. return CMD_SUCCESS;
  1396. }
  1397. DEFUN (no_neighbor_peer_group_remote_as,
  1398. no_neighbor_peer_group_remote_as_cmd,
  1399. "no neighbor WORD remote-as " CMD_AS_RANGE,
  1400. NO_STR
  1401. NEIGHBOR_STR
  1402. "Neighbor tag\n"
  1403. "Specify a BGP neighbor\n"
  1404. AS_STR)
  1405. {
  1406. struct peer_group *group;
  1407. group = peer_group_lookup (vty->index, argv[0]);
  1408. if (group)
  1409. peer_group_remote_as_delete (group);
  1410. else
  1411. {
  1412. vty_out (vty, "%% Create the peer-group first%s", VTY_NEWLINE);
  1413. return CMD_WARNING;
  1414. }
  1415. return CMD_SUCCESS;
  1416. }
  1417. DEFUN (neighbor_local_as,
  1418. neighbor_local_as_cmd,
  1419. NEIGHBOR_CMD2 "local-as " CMD_AS_RANGE,
  1420. NEIGHBOR_STR
  1421. NEIGHBOR_ADDR_STR2
  1422. "Specify a local-as number\n"
  1423. "AS number used as local AS\n")
  1424. {
  1425. struct peer *peer;
  1426. int ret;
  1427. peer = peer_and_group_lookup_vty (vty, argv[0]);
  1428. if (! peer)
  1429. return CMD_WARNING;
  1430. ret = peer_local_as_set (peer, atoi (argv[1]), 0, 0);
  1431. return bgp_vty_return (vty, ret);
  1432. }
  1433. DEFUN (neighbor_local_as_no_prepend,
  1434. neighbor_local_as_no_prepend_cmd,
  1435. NEIGHBOR_CMD2 "local-as " CMD_AS_RANGE " no-prepend",
  1436. NEIGHBOR_STR
  1437. NEIGHBOR_ADDR_STR2
  1438. "Specify a local-as number\n"
  1439. "AS number used as local AS\n"
  1440. "Do not prepend local-as to updates from ebgp peers\n")
  1441. {
  1442. struct peer *peer;
  1443. int ret;
  1444. peer = peer_and_group_lookup_vty (vty, argv[0]);
  1445. if (! peer)
  1446. return CMD_WARNING;
  1447. ret = peer_local_as_set (peer, atoi (argv[1]), 1, 0);
  1448. return bgp_vty_return (vty, ret);
  1449. }
  1450. DEFUN (neighbor_local_as_no_prepend_replace_as,
  1451. neighbor_local_as_no_prepend_replace_as_cmd,
  1452. NEIGHBOR_CMD2 "local-as " CMD_AS_RANGE " no-prepend replace-as",
  1453. NEIGHBOR_STR
  1454. NEIGHBOR_ADDR_STR2
  1455. "Specify a local-as number\n"
  1456. "AS number used as local AS\n"
  1457. "Do not prepend local-as to updates from ebgp peers\n"
  1458. "Do not prepend local-as to updates from ibgp peers\n")
  1459. {
  1460. struct peer *peer;
  1461. int ret;
  1462. peer = peer_and_group_lookup_vty (vty, argv[0]);
  1463. if (! peer)
  1464. return CMD_WARNING;
  1465. ret = peer_local_as_set (peer, atoi (argv[1]), 1, 1);
  1466. return bgp_vty_return (vty, ret);
  1467. }
  1468. DEFUN (no_neighbor_local_as,
  1469. no_neighbor_local_as_cmd,
  1470. NO_NEIGHBOR_CMD2 "local-as",
  1471. NO_STR
  1472. NEIGHBOR_STR
  1473. NEIGHBOR_ADDR_STR2
  1474. "Specify a local-as number\n")
  1475. {
  1476. struct peer *peer;
  1477. int ret;
  1478. peer = peer_and_group_lookup_vty (vty, argv[0]);
  1479. if (! peer)
  1480. return CMD_WARNING;
  1481. ret = peer_local_as_unset (peer);
  1482. return bgp_vty_return (vty, ret);
  1483. }
  1484. ALIAS (no_neighbor_local_as,
  1485. no_neighbor_local_as_val_cmd,
  1486. NO_NEIGHBOR_CMD2 "local-as " CMD_AS_RANGE,
  1487. NO_STR
  1488. NEIGHBOR_STR
  1489. NEIGHBOR_ADDR_STR2
  1490. "Specify a local-as number\n"
  1491. "AS number used as local AS\n")
  1492. ALIAS (no_neighbor_local_as,
  1493. no_neighbor_local_as_val2_cmd,
  1494. NO_NEIGHBOR_CMD2 "local-as " CMD_AS_RANGE " no-prepend",
  1495. NO_STR
  1496. NEIGHBOR_STR
  1497. NEIGHBOR_ADDR_STR2
  1498. "Specify a local-as number\n"
  1499. "AS number used as local AS\n"
  1500. "Do not prepend local-as to updates from ebgp peers\n")
  1501. ALIAS (no_neighbor_local_as,
  1502. no_neighbor_local_as_val3_cmd,
  1503. NO_NEIGHBOR_CMD2 "local-as " CMD_AS_RANGE " no-prepend replace-as",
  1504. NO_STR
  1505. NEIGHBOR_STR
  1506. NEIGHBOR_ADDR_STR2
  1507. "Specify a local-as number\n"
  1508. "AS number used as local AS\n"
  1509. "Do not prepend local-as to updates from ebgp peers\n"
  1510. "Do not prepend local-as to updates from ibgp peers\n")
  1511. DEFUN (neighbor_password,
  1512. neighbor_password_cmd,
  1513. NEIGHBOR_CMD2 "password LINE",
  1514. NEIGHBOR_STR
  1515. NEIGHBOR_ADDR_STR2
  1516. "Set a password\n"
  1517. "The password\n")
  1518. {
  1519. struct peer *peer;
  1520. int ret;
  1521. peer = peer_and_group_lookup_vty (vty, argv[0]);
  1522. if (! peer)
  1523. return CMD_WARNING;
  1524. ret = peer_password_set (peer, argv[1]);
  1525. return bgp_vty_return (vty, ret);
  1526. }
  1527. DEFUN (no_neighbor_password,
  1528. no_neighbor_password_cmd,
  1529. NO_NEIGHBOR_CMD2 "password",
  1530. NO_STR
  1531. NEIGHBOR_STR
  1532. NEIGHBOR_ADDR_STR2
  1533. "Set a password\n")
  1534. {
  1535. struct peer *peer;
  1536. int ret;
  1537. peer = peer_and_group_lookup_vty (vty, argv[0]);
  1538. if (! peer)
  1539. return CMD_WARNING;
  1540. ret = peer_password_unset (peer);
  1541. return bgp_vty_return (vty, ret);
  1542. }
  1543. DEFUN (neighbor_activate,
  1544. neighbor_activate_cmd,
  1545. NEIGHBOR_CMD2 "activate",
  1546. NEIGHBOR_STR
  1547. NEIGHBOR_ADDR_STR2
  1548. "Enable the Address Family for this Neighbor\n")
  1549. {
  1550. struct peer *peer;
  1551. peer = peer_and_group_lookup_vty (vty, argv[0]);
  1552. if (! peer)
  1553. return CMD_WARNING;
  1554. peer_activate (peer, bgp_node_afi (vty), bgp_node_safi (vty));
  1555. return CMD_SUCCESS;
  1556. }
  1557. DEFUN (no_neighbor_activate,
  1558. no_neighbor_activate_cmd,
  1559. NO_NEIGHBOR_CMD2 "activate",
  1560. NO_STR
  1561. NEIGHBOR_STR
  1562. NEIGHBOR_ADDR_STR2
  1563. "Enable the Address Family for this Neighbor\n")
  1564. {
  1565. int ret;
  1566. struct peer *peer;
  1567. /* Lookup peer. */
  1568. peer = peer_and_group_lookup_vty (vty, argv[0]);
  1569. if (! peer)
  1570. return CMD_WARNING;
  1571. ret = peer_deactivate (peer, bgp_node_afi (vty), bgp_node_safi (vty));
  1572. return bgp_vty_return (vty, ret);
  1573. }
  1574. DEFUN (neighbor_set_peer_group,
  1575. neighbor_set_peer_group_cmd,
  1576. NEIGHBOR_CMD "peer-group WORD",
  1577. NEIGHBOR_STR
  1578. NEIGHBOR_ADDR_STR
  1579. "Member of the peer-group\n"
  1580. "peer-group name\n")
  1581. {
  1582. int ret;
  1583. as_t as;
  1584. union sockunion su;
  1585. struct bgp *bgp;
  1586. struct peer_group *group;
  1587. bgp = vty->index;
  1588. ret = str2sockunion (argv[0], &su);
  1589. if (ret < 0)
  1590. {
  1591. vty_out (vty, "%% Malformed address: %s%s", argv[0], VTY_NEWLINE);
  1592. return CMD_WARNING;
  1593. }
  1594. group = peer_group_lookup (bgp, argv[1]);
  1595. if (! group)
  1596. {
  1597. vty_out (vty, "%% Configure the peer-group first%s", VTY_NEWLINE);
  1598. return CMD_WARNING;
  1599. }
  1600. if (peer_address_self_check (&su))
  1601. {
  1602. vty_out (vty, "%% Can not configure the local system as neighbor%s",
  1603. VTY_NEWLINE);
  1604. return CMD_WARNING;
  1605. }
  1606. ret = peer_group_bind (bgp, &su, group, bgp_node_afi (vty),
  1607. bgp_node_safi (vty), &as);
  1608. if (ret == BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT)
  1609. {
  1610. vty_out (vty, "%% Peer with AS %u cannot be in this peer-group, members must be all internal or all external%s", as, VTY_NEWLINE);
  1611. return CMD_WARNING;
  1612. }
  1613. return bgp_vty_return (vty, ret);
  1614. }
  1615. DEFUN (no_neighbor_set_peer_group,
  1616. no_neighbor_set_peer_group_cmd,
  1617. NO_NEIGHBOR_CMD "peer-group WORD",
  1618. NO_STR
  1619. NEIGHBOR_STR
  1620. NEIGHBOR_ADDR_STR
  1621. "Member of the peer-group\n"
  1622. "peer-group name\n")
  1623. {
  1624. int ret;
  1625. struct bgp *bgp;
  1626. struct peer *peer;
  1627. struct peer_group *group;
  1628. bgp = vty->index;
  1629. peer = peer_lookup_vty (vty, argv[0]);
  1630. if (! peer)
  1631. return CMD_WARNING;
  1632. group = peer_group_lookup (bgp, argv[1]);
  1633. if (! group)
  1634. {
  1635. vty_out (vty, "%% Configure the peer-group first%s", VTY_NEWLINE);
  1636. return CMD_WARNING;
  1637. }
  1638. ret = peer_group_unbind (bgp, peer, group, bgp_node_afi (vty),
  1639. bgp_node_safi (vty));
  1640. return bgp_vty_return (vty, ret);
  1641. }
  1642. static int
  1643. peer_flag_modify_vty (struct vty *vty, const char *ip_str,
  1644. u_int16_t flag, int set)
  1645. {
  1646. int ret;
  1647. struct peer *peer;
  1648. peer = peer_and_group_lookup_vty (vty, ip_str);
  1649. if (! peer)
  1650. return CMD_WARNING;
  1651. if (set)
  1652. ret = peer_flag_set (peer, flag);
  1653. else
  1654. ret = peer_flag_unset (peer, flag);
  1655. return bgp_vty_return (vty, ret);
  1656. }
  1657. static int
  1658. peer_flag_set_vty (struct vty *vty, const char *ip_str, u_int16_t flag)
  1659. {
  1660. return peer_flag_modify_vty (vty, ip_str, flag, 1);
  1661. }
  1662. static int
  1663. peer_flag_unset_vty (struct vty *vty, const char *ip_str, u_int16_t flag)
  1664. {
  1665. return peer_flag_modify_vty (vty, ip_str, flag, 0);
  1666. }
  1667. /* neighbor passive. */
  1668. DEFUN (neighbor_passive,
  1669. neighbor_passive_cmd,
  1670. NEIGHBOR_CMD2 "passive",
  1671. NEIGHBOR_STR
  1672. NEIGHBOR_ADDR_STR2
  1673. "Don't send open messages to this neighbor\n")
  1674. {
  1675. return peer_flag_set_vty (vty, argv[0], PEER_FLAG_PASSIVE);
  1676. }
  1677. DEFUN (no_neighbor_passive,
  1678. no_neighbor_passive_cmd,
  1679. NO_NEIGHBOR_CMD2 "passive",
  1680. NO_STR
  1681. NEIGHBOR_STR
  1682. NEIGHBOR_ADDR_STR2
  1683. "Don't send open messages to this neighbor\n")
  1684. {
  1685. return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_PASSIVE);
  1686. }
  1687. /* neighbor shutdown. */
  1688. DEFUN (neighbor_shutdown,
  1689. neighbor_shutdown_cmd,
  1690. NEIGHBOR_CMD2 "shutdown",
  1691. NEIGHBOR_STR
  1692. NEIGHBOR_ADDR_STR2
  1693. "Administratively shut down this neighbor\n")
  1694. {
  1695. return peer_flag_set_vty (vty, argv[0], PEER_FLAG_SHUTDOWN);
  1696. }
  1697. DEFUN (no_neighbor_shutdown,
  1698. no_neighbor_shutdown_cmd,
  1699. NO_NEIGHBOR_CMD2 "shutdown",
  1700. NO_STR
  1701. NEIGHBOR_STR
  1702. NEIGHBOR_ADDR_STR2
  1703. "Administratively shut down this neighbor\n")
  1704. {
  1705. return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_SHUTDOWN);
  1706. }
  1707. /* Deprecated neighbor capability route-refresh. */
  1708. DEFUN_DEPRECATED (neighbor_capability_route_refresh,
  1709. neighbor_capability_route_refresh_cmd,
  1710. NEIGHBOR_CMD2 "capability route-refresh",
  1711. NEIGHBOR_STR
  1712. NEIGHBOR_ADDR_STR2
  1713. "Advertise capability to the peer\n"
  1714. "Advertise route-refresh capability to this neighbor\n")
  1715. {
  1716. return CMD_SUCCESS;
  1717. }
  1718. DEFUN_DEPRECATED (no_neighbor_capability_route_refresh,
  1719. no_neighbor_capability_route_refresh_cmd,
  1720. NO_NEIGHBOR_CMD2 "capability route-refresh",
  1721. NO_STR
  1722. NEIGHBOR_STR
  1723. NEIGHBOR_ADDR_STR2
  1724. "Advertise capability to the peer\n"
  1725. "Advertise route-refresh capability to this neighbor\n")
  1726. {
  1727. return CMD_SUCCESS;
  1728. }
  1729. /* neighbor capability dynamic. */
  1730. DEFUN (neighbor_capability_dynamic,
  1731. neighbor_capability_dynamic_cmd,
  1732. NEIGHBOR_CMD2 "capability dynamic",
  1733. NEIGHBOR_STR
  1734. NEIGHBOR_ADDR_STR2
  1735. "Advertise capability to the peer\n"
  1736. "Advertise dynamic capability to this neighbor\n")
  1737. {
  1738. return peer_flag_set_vty (vty, argv[0], PEER_FLAG_DYNAMIC_CAPABILITY);
  1739. }
  1740. DEFUN (no_neighbor_capability_dynamic,
  1741. no_neighbor_capability_dynamic_cmd,
  1742. NO_NEIGHBOR_CMD2 "capability dynamic",
  1743. NO_STR
  1744. NEIGHBOR_STR
  1745. NEIGHBOR_ADDR_STR2
  1746. "Advertise capability to the peer\n"
  1747. "Advertise dynamic capability to this neighbor\n")
  1748. {
  1749. return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_DYNAMIC_CAPABILITY);
  1750. }
  1751. /* neighbor dont-capability-negotiate */
  1752. DEFUN (neighbor_dont_capability_negotiate,
  1753. neighbor_dont_capability_negotiate_cmd,
  1754. NEIGHBOR_CMD2 "dont-capability-negotiate",
  1755. NEIGHBOR_STR
  1756. NEIGHBOR_ADDR_STR2
  1757. "Do not perform capability negotiation\n")
  1758. {
  1759. return peer_flag_set_vty (vty, argv[0], PEER_FLAG_DONT_CAPABILITY);
  1760. }
  1761. DEFUN (no_neighbor_dont_capability_negotiate,
  1762. no_neighbor_dont_capability_negotiate_cmd,
  1763. NO_NEIGHBOR_CMD2 "dont-capability-negotiate",
  1764. NO_STR
  1765. NEIGHBOR_STR
  1766. NEIGHBOR_ADDR_STR2
  1767. "Do not perform capability negotiation\n")
  1768. {
  1769. return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_DONT_CAPABILITY);
  1770. }
  1771. static int
  1772. peer_af_flag_modify_vty (struct vty *vty, const char *peer_str, afi_t afi,
  1773. safi_t safi, u_int32_t flag, int set)
  1774. {
  1775. int ret;
  1776. struct peer *peer;
  1777. peer = peer_and_group_lookup_vty (vty, peer_str);
  1778. if (! peer)
  1779. return CMD_WARNING;
  1780. if (set)
  1781. ret = peer_af_flag_set (peer, afi, safi, flag);
  1782. else
  1783. ret = peer_af_flag_unset (peer, afi, safi, flag);
  1784. return bgp_vty_return (vty, ret);
  1785. }
  1786. static int
  1787. peer_af_flag_set_vty (struct vty *vty, const char *peer_str, afi_t afi,
  1788. safi_t safi, u_int32_t flag)
  1789. {
  1790. return peer_af_flag_modify_vty (vty, peer_str, afi, safi, flag, 1);
  1791. }
  1792. static int
  1793. peer_af_flag_unset_vty (struct vty *vty, const char *peer_str, afi_t afi,
  1794. safi_t safi, u_int32_t flag)
  1795. {
  1796. return peer_af_flag_modify_vty (vty, peer_str, afi, safi, flag, 0);
  1797. }
  1798. /* neighbor capability orf prefix-list. */
  1799. DEFUN (neighbor_capability_orf_prefix,
  1800. neighbor_capability_orf_prefix_cmd,
  1801. NEIGHBOR_CMD2 "capability orf prefix-list (both|send|receive)",
  1802. NEIGHBOR_STR
  1803. NEIGHBOR_ADDR_STR2
  1804. "Advertise capability to the peer\n"
  1805. "Advertise ORF capability to the peer\n"
  1806. "Advertise prefixlist ORF capability to this neighbor\n"
  1807. "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
  1808. "Capability to RECEIVE the ORF from this neighbor\n"
  1809. "Capability to SEND the ORF to this neighbor\n")
  1810. {
  1811. u_int16_t flag = 0;
  1812. if (strncmp (argv[1], "s", 1) == 0)
  1813. flag = PEER_FLAG_ORF_PREFIX_SM;
  1814. else if (strncmp (argv[1], "r", 1) == 0)
  1815. flag = PEER_FLAG_ORF_PREFIX_RM;
  1816. else if (strncmp (argv[1], "b", 1) == 0)
  1817. flag = PEER_FLAG_ORF_PREFIX_SM|PEER_FLAG_ORF_PREFIX_RM;
  1818. else
  1819. return CMD_WARNING;
  1820. return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
  1821. bgp_node_safi (vty), flag);
  1822. }
  1823. DEFUN (no_neighbor_capability_orf_prefix,
  1824. no_neighbor_capability_orf_prefix_cmd,
  1825. NO_NEIGHBOR_CMD2 "capability orf prefix-list (both|send|receive)",
  1826. NO_STR
  1827. NEIGHBOR_STR
  1828. NEIGHBOR_ADDR_STR2
  1829. "Advertise capability to the peer\n"
  1830. "Advertise ORF capability to the peer\n"
  1831. "Advertise prefixlist ORF capability to this neighbor\n"
  1832. "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
  1833. "Capability to RECEIVE the ORF from this neighbor\n"
  1834. "Capability to SEND the ORF to this neighbor\n")
  1835. {
  1836. u_int16_t flag = 0;
  1837. if (strncmp (argv[1], "s", 1) == 0)
  1838. flag = PEER_FLAG_ORF_PREFIX_SM;
  1839. else if (strncmp (argv[1], "r", 1) == 0)
  1840. flag = PEER_FLAG_ORF_PREFIX_RM;
  1841. else if (strncmp (argv[1], "b", 1) == 0)
  1842. flag = PEER_FLAG_ORF_PREFIX_SM|PEER_FLAG_ORF_PREFIX_RM;
  1843. else
  1844. return CMD_WARNING;
  1845. return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
  1846. bgp_node_safi (vty), flag);
  1847. }
  1848. /* neighbor next-hop-self. */
  1849. DEFUN (neighbor_nexthop_self,
  1850. neighbor_nexthop_self_cmd,
  1851. NEIGHBOR_CMD2 "next-hop-self {all}",
  1852. NEIGHBOR_STR
  1853. NEIGHBOR_ADDR_STR2
  1854. "Disable the next hop calculation for this neighbor\n"
  1855. "Apply also to ibgp-learned routes when acting as a route reflector\n")
  1856. {
  1857. u_int32_t flags = PEER_FLAG_NEXTHOP_SELF, unset = 0;
  1858. int rc;
  1859. /* Check if "all" is specified */
  1860. if (argv[1] != NULL)
  1861. flags |= PEER_FLAG_NEXTHOP_SELF_ALL;
  1862. else
  1863. unset |= PEER_FLAG_NEXTHOP_SELF_ALL;
  1864. rc = peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
  1865. bgp_node_safi (vty), flags);
  1866. if ( rc == CMD_SUCCESS && unset )
  1867. rc = peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
  1868. bgp_node_safi (vty), unset);
  1869. return rc;
  1870. }
  1871. DEFUN (no_neighbor_nexthop_self,
  1872. no_neighbor_nexthop_self_cmd,
  1873. NO_NEIGHBOR_CMD2 "next-hop-self {all}",
  1874. NO_STR
  1875. NEIGHBOR_STR
  1876. NEIGHBOR_ADDR_STR2
  1877. "Disable the next hop calculation for this neighbor\n"
  1878. "Apply also to ibgp-learned routes when acting as a route reflector\n")
  1879. {
  1880. return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
  1881. bgp_node_safi (vty),
  1882. PEER_FLAG_NEXTHOP_SELF|PEER_FLAG_NEXTHOP_SELF_ALL);
  1883. }
  1884. /* neighbor remove-private-AS. */
  1885. DEFUN (neighbor_remove_private_as,
  1886. neighbor_remove_private_as_cmd,
  1887. NEIGHBOR_CMD2 "remove-private-AS",
  1888. NEIGHBOR_STR
  1889. NEIGHBOR_ADDR_STR2
  1890. "Remove private AS number from outbound updates\n")
  1891. {
  1892. return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
  1893. bgp_node_safi (vty),
  1894. PEER_FLAG_REMOVE_PRIVATE_AS);
  1895. }
  1896. DEFUN (no_neighbor_remove_private_as,
  1897. no_neighbor_remove_private_as_cmd,
  1898. NO_NEIGHBOR_CMD2 "remove-private-AS",
  1899. NO_STR
  1900. NEIGHBOR_STR
  1901. NEIGHBOR_ADDR_STR2
  1902. "Remove private AS number from outbound updates\n")
  1903. {
  1904. return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
  1905. bgp_node_safi (vty),
  1906. PEER_FLAG_REMOVE_PRIVATE_AS);
  1907. }
  1908. /* neighbor send-community. */
  1909. DEFUN (neighbor_send_community,
  1910. neighbor_send_community_cmd,
  1911. NEIGHBOR_CMD2 "send-community",
  1912. NEIGHBOR_STR
  1913. NEIGHBOR_ADDR_STR2
  1914. "Send Community attribute to this neighbor\n")
  1915. {
  1916. return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
  1917. bgp_node_safi (vty),
  1918. PEER_FLAG_SEND_COMMUNITY);
  1919. }
  1920. DEFUN (no_neighbor_send_community,
  1921. no_neighbor_send_community_cmd,
  1922. NO_NEIGHBOR_CMD2 "send-community",
  1923. NO_STR
  1924. NEIGHBOR_STR
  1925. NEIGHBOR_ADDR_STR2
  1926. "Send Community attribute to this neighbor\n")
  1927. {
  1928. return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
  1929. bgp_node_safi (vty),
  1930. PEER_FLAG_SEND_COMMUNITY);
  1931. }
  1932. /* neighbor send-community extended. */
  1933. DEFUN (neighbor_send_community_type,
  1934. neighbor_send_community_type_cmd,
  1935. NEIGHBOR_CMD2 "send-community (both|extended|standard)",
  1936. NEIGHBOR_STR
  1937. NEIGHBOR_ADDR_STR2
  1938. "Send Community attribute to this neighbor\n"
  1939. "Send Standard and Extended Community attributes\n"
  1940. "Send Extended Community attributes\n"
  1941. "Send Standard Community attributes\n")
  1942. {
  1943. if (strncmp (argv[1], "s", 1) == 0)
  1944. return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
  1945. bgp_node_safi (vty),
  1946. PEER_FLAG_SEND_COMMUNITY);
  1947. if (strncmp (argv[1], "e", 1) == 0)
  1948. return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
  1949. bgp_node_safi (vty),
  1950. PEER_FLAG_SEND_EXT_COMMUNITY);
  1951. return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
  1952. bgp_node_safi (vty),
  1953. (PEER_FLAG_SEND_COMMUNITY|
  1954. PEER_FLAG_SEND_EXT_COMMUNITY));
  1955. }
  1956. DEFUN (no_neighbor_send_community_type,
  1957. no_neighbor_send_community_type_cmd,
  1958. NO_NEIGHBOR_CMD2 "send-community (both|extended|standard)",
  1959. NO_STR
  1960. NEIGHBOR_STR
  1961. NEIGHBOR_ADDR_STR2
  1962. "Send Community attribute to this neighbor\n"
  1963. "Send Standard and Extended Community attributes\n"
  1964. "Send Extended Community attributes\n"
  1965. "Send Standard Community attributes\n")
  1966. {
  1967. if (strncmp (argv[1], "s", 1) == 0)
  1968. return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
  1969. bgp_node_safi (vty),
  1970. PEER_FLAG_SEND_COMMUNITY);
  1971. if (strncmp (argv[1], "e", 1) == 0)
  1972. return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
  1973. bgp_node_safi (vty),
  1974. PEER_FLAG_SEND_EXT_COMMUNITY);
  1975. return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
  1976. bgp_node_safi (vty),
  1977. (PEER_FLAG_SEND_COMMUNITY |
  1978. PEER_FLAG_SEND_EXT_COMMUNITY));
  1979. }
  1980. /* neighbor soft-reconfig. */
  1981. DEFUN (neighbor_soft_reconfiguration,
  1982. neighbor_soft_reconfiguration_cmd,
  1983. NEIGHBOR_CMD2 "soft-reconfiguration inbound",
  1984. NEIGHBOR_STR
  1985. NEIGHBOR_ADDR_STR2
  1986. "Per neighbor soft reconfiguration\n"
  1987. "Allow inbound soft reconfiguration for this neighbor\n")
  1988. {
  1989. return peer_af_flag_set_vty (vty, argv[0],
  1990. bgp_node_afi (vty), bgp_node_safi (vty),
  1991. PEER_FLAG_SOFT_RECONFIG);
  1992. }
  1993. DEFUN (no_neighbor_soft_reconfiguration,
  1994. no_neighbor_soft_reconfiguration_cmd,
  1995. NO_NEIGHBOR_CMD2 "soft-reconfiguration inbound",
  1996. NO_STR
  1997. NEIGHBOR_STR
  1998. NEIGHBOR_ADDR_STR2
  1999. "Per neighbor soft reconfiguration\n"
  2000. "Allow inbound soft reconfiguration for this neighbor\n")
  2001. {
  2002. return peer_af_flag_unset_vty (vty, argv[0],
  2003. bgp_node_afi (vty), bgp_node_safi (vty),
  2004. PEER_FLAG_SOFT_RECONFIG);
  2005. }
  2006. DEFUN (neighbor_route_reflector_client,
  2007. neighbor_route_reflector_client_cmd,
  2008. NEIGHBOR_CMD2 "route-reflector-client",
  2009. NEIGHBOR_STR
  2010. NEIGHBOR_ADDR_STR2
  2011. "Configure a neighbor as Route Reflector client\n")
  2012. {
  2013. struct peer *peer;
  2014. peer = peer_and_group_lookup_vty (vty, argv[0]);
  2015. if (! peer)
  2016. return CMD_WARNING;
  2017. return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
  2018. bgp_node_safi (vty),
  2019. PEER_FLAG_REFLECTOR_CLIENT);
  2020. }
  2021. DEFUN (no_neighbor_route_reflector_client,
  2022. no_neighbor_route_reflector_client_cmd,
  2023. NO_NEIGHBOR_CMD2 "route-reflector-client",
  2024. NO_STR
  2025. NEIGHBOR_STR
  2026. NEIGHBOR_ADDR_STR2
  2027. "Configure a neighbor as Route Reflector client\n")
  2028. {
  2029. return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
  2030. bgp_node_safi (vty),
  2031. PEER_FLAG_REFLECTOR_CLIENT);
  2032. }
  2033. static int
  2034. peer_rsclient_set_vty (struct vty *vty, const char *peer_str,
  2035. int afi, int safi)
  2036. {
  2037. int ret;
  2038. struct bgp *bgp;
  2039. struct peer *peer;
  2040. struct peer_group *group;
  2041. struct listnode *node, *nnode;
  2042. struct bgp_filter *pfilter;
  2043. struct bgp_filter *gfilter;
  2044. int locked_and_added = 0;
  2045. bgp = vty->index;
  2046. peer = peer_and_group_lookup_vty (vty, peer_str);
  2047. if ( ! peer )
  2048. return CMD_WARNING;
  2049. /* If it is already a RS-Client, don't do anything. */
  2050. if ( CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT) )
  2051. return CMD_SUCCESS;
  2052. if ( ! peer_rsclient_active (peer) )
  2053. {
  2054. peer = peer_lock (peer); /* rsclient peer list reference */
  2055. listnode_add_sort (bgp->rsclient, peer);
  2056. locked_and_added = 1;
  2057. }
  2058. ret = peer_af_flag_set (peer, afi, safi, PEER_FLAG_RSERVER_CLIENT);
  2059. if (ret < 0)
  2060. {
  2061. if (locked_and_added)
  2062. {
  2063. listnode_delete (bgp->rsclient, peer);
  2064. peer_unlock (peer); /* rsclient peer list reference */
  2065. }
  2066. return bgp_vty_return (vty, ret);
  2067. }
  2068. peer->rib[afi][safi] = bgp_table_init (afi, safi);
  2069. peer->rib[afi][safi]->type = BGP_TABLE_RSCLIENT;
  2070. /* RIB peer reference. Released when table is free'd in bgp_table_free. */
  2071. peer->rib[afi][safi]->owner = peer_lock (peer);
  2072. /* Check for existing 'network' and 'redistribute' routes. */
  2073. bgp_check_local_routes_rsclient (peer, afi, safi);
  2074. /* Check for routes for peers configured with 'soft-reconfiguration'. */
  2075. bgp_soft_reconfig_rsclient (peer, afi, safi);
  2076. if (CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP))
  2077. {
  2078. group = peer->group;
  2079. gfilter = &peer->filter[afi][safi];
  2080. for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
  2081. {
  2082. pfilter = &peer->filter[afi][safi];
  2083. /* Members of a non-RS-Client group should not be RS-Clients, as that
  2084. is checked when the become part of the peer-group */
  2085. ret = peer_af_flag_set (peer, afi, safi, PEER_FLAG_RSERVER_CLIENT);
  2086. if (ret < 0)
  2087. return bgp_vty_return (vty, ret);
  2088. /* Make peer's RIB point to group's RIB. */
  2089. peer->rib[afi][safi] = group->conf->rib[afi][safi];
  2090. /* Import policy. */
  2091. if (pfilter->map[RMAP_IMPORT].name)
  2092. free (pfilter->map[RMAP_IMPORT].name);
  2093. if (gfilter->map[RMAP_IMPORT].name)
  2094. {
  2095. pfilter->map[RMAP_IMPORT].name = strdup (gfilter->map[RMAP_IMPORT].name);
  2096. pfilter->map[RMAP_IMPORT].map = gfilter->map[RMAP_IMPORT].map;
  2097. }
  2098. else
  2099. {
  2100. pfilter->map[RMAP_IMPORT].name = NULL;
  2101. pfilter->map[RMAP_IMPORT].map =NULL;
  2102. }
  2103. /* Export policy. */
  2104. if (gfilter->map[RMAP_EXPORT].name && ! pfilter->map[RMAP_EXPORT].name)
  2105. {
  2106. pfilter->map[RMAP_EXPORT].name = strdup (gfilter->map[RMAP_EXPORT].name);
  2107. pfilter->map[RMAP_EXPORT].map = gfilter->map[RMAP_EXPORT].map;
  2108. }
  2109. }
  2110. }
  2111. return CMD_SUCCESS;
  2112. }
  2113. static int
  2114. peer_rsclient_unset_vty (struct vty *vty, const char *peer_str,
  2115. int afi, int safi)
  2116. {
  2117. int ret;
  2118. struct bgp *bgp;
  2119. struct peer *peer;
  2120. struct peer_group *group;
  2121. struct listnode *node, *nnode;
  2122. bgp = vty->index;
  2123. peer = peer_and_group_lookup_vty (vty, peer_str);
  2124. if ( ! peer )
  2125. return CMD_WARNING;
  2126. /* If it is not a RS-Client, don't do anything. */
  2127. if ( ! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT) )
  2128. return CMD_SUCCESS;
  2129. if (CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP))
  2130. {
  2131. group = peer->group;
  2132. for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
  2133. {
  2134. ret = peer_af_flag_unset (peer, afi, safi, PEER_FLAG_RSERVER_CLIENT);
  2135. if (ret < 0)
  2136. return bgp_vty_return (vty, ret);
  2137. peer->rib[afi][safi] = NULL;
  2138. }
  2139. peer = group->conf;
  2140. }
  2141. ret = peer_af_flag_unset (peer, afi, safi, PEER_FLAG_RSERVER_CLIENT);
  2142. if (ret < 0)
  2143. return bgp_vty_return (vty, ret);
  2144. if ( ! peer_rsclient_active (peer) )
  2145. {
  2146. bgp_clear_route (peer, afi, safi, BGP_CLEAR_ROUTE_MY_RSCLIENT);
  2147. listnode_delete (bgp->rsclient, peer);
  2148. peer_unlock (peer); /* peer bgp rsclient reference */
  2149. }
  2150. bgp_table_finish (&peer->rib[bgp_node_afi(vty)][bgp_node_safi(vty)]);
  2151. return CMD_SUCCESS;
  2152. }
  2153. /* neighbor route-server-client. */
  2154. DEFUN (neighbor_route_server_client,
  2155. neighbor_route_server_client_cmd,
  2156. NEIGHBOR_CMD2 "route-server-client",
  2157. NEIGHBOR_STR
  2158. NEIGHBOR_ADDR_STR2
  2159. "Configure a neighbor as Route Server client\n")
  2160. {
  2161. return peer_rsclient_set_vty (vty, argv[0], bgp_node_afi(vty),
  2162. bgp_node_safi(vty));
  2163. }
  2164. DEFUN (no_neighbor_route_server_client,
  2165. no_neighbor_route_server_client_cmd,
  2166. NO_NEIGHBOR_CMD2 "route-server-client",
  2167. NO_STR
  2168. NEIGHBOR_STR
  2169. NEIGHBOR_ADDR_STR2
  2170. "Configure a neighbor as Route Server client\n")
  2171. {
  2172. return peer_rsclient_unset_vty (vty, argv[0], bgp_node_afi(vty),
  2173. bgp_node_safi(vty));
  2174. }
  2175. DEFUN (neighbor_nexthop_local_unchanged,
  2176. neighbor_nexthop_local_unchanged_cmd,
  2177. NEIGHBOR_CMD2 "nexthop-local unchanged",
  2178. NEIGHBOR_STR
  2179. NEIGHBOR_ADDR_STR2
  2180. "Configure treatment of outgoing link-local nexthop attribute\n"
  2181. "Leave link-local nexthop unchanged for this peer\n")
  2182. {
  2183. return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
  2184. bgp_node_safi (vty),
  2185. PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED );
  2186. }
  2187. DEFUN (no_neighbor_nexthop_local_unchanged,
  2188. no_neighbor_nexthop_local_unchanged_cmd,
  2189. NO_NEIGHBOR_CMD2 "nexthop-local unchanged",
  2190. NO_STR
  2191. NEIGHBOR_STR
  2192. NEIGHBOR_ADDR_STR2
  2193. "Configure treatment of outgoing link-local-nexthop attribute\n"
  2194. "Leave link-local nexthop unchanged for this peer\n")
  2195. {
  2196. return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
  2197. bgp_node_safi (vty),
  2198. PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED );
  2199. }
  2200. DEFUN (neighbor_attr_unchanged,
  2201. neighbor_attr_unchanged_cmd,
  2202. NEIGHBOR_CMD2 "attribute-unchanged",
  2203. NEIGHBOR_STR
  2204. NEIGHBOR_ADDR_STR2
  2205. "BGP attribute is propagated unchanged to this neighbor\n")
  2206. {
  2207. return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
  2208. bgp_node_safi (vty),
  2209. (PEER_FLAG_AS_PATH_UNCHANGED |
  2210. PEER_FLAG_NEXTHOP_UNCHANGED |
  2211. PEER_FLAG_MED_UNCHANGED));
  2212. }
  2213. DEFUN (neighbor_attr_unchanged1,
  2214. neighbor_attr_unchanged1_cmd,
  2215. NEIGHBOR_CMD2 "attribute-unchanged (as-path|next-hop|med)",
  2216. NEIGHBOR_STR
  2217. NEIGHBOR_ADDR_STR2
  2218. "BGP attribute is propagated unchanged to this neighbor\n"
  2219. "As-path attribute\n"
  2220. "Nexthop attribute\n"
  2221. "Med attribute\n")
  2222. {
  2223. u_int16_t flags = 0;
  2224. if (strncmp (argv[1], "as-path", 1) == 0)
  2225. SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED);
  2226. else if (strncmp (argv[1], "next-hop", 1) == 0)
  2227. SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED);
  2228. else if (strncmp (argv[1], "med", 1) == 0)
  2229. SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED);
  2230. return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
  2231. bgp_node_safi (vty), flags);
  2232. }
  2233. DEFUN (neighbor_attr_unchanged2,
  2234. neighbor_attr_unchanged2_cmd,
  2235. NEIGHBOR_CMD2 "attribute-unchanged as-path (next-hop|med)",
  2236. NEIGHBOR_STR
  2237. NEIGHBOR_ADDR_STR2
  2238. "BGP attribute is propagated unchanged to this neighbor\n"
  2239. "As-path attribute\n"
  2240. "Nexthop attribute\n"
  2241. "Med attribute\n")
  2242. {
  2243. u_int16_t flags = PEER_FLAG_AS_PATH_UNCHANGED;
  2244. if (strncmp (argv[1], "next-hop", 1) == 0)
  2245. SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED);
  2246. else if (strncmp (argv[1], "med", 1) == 0)
  2247. SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED);
  2248. return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
  2249. bgp_node_safi (vty), flags);
  2250. }
  2251. DEFUN (neighbor_attr_unchanged3,
  2252. neighbor_attr_unchanged3_cmd,
  2253. NEIGHBOR_CMD2 "attribute-unchanged next-hop (as-path|med)",
  2254. NEIGHBOR_STR
  2255. NEIGHBOR_ADDR_STR2
  2256. "BGP attribute is propagated unchanged to this neighbor\n"
  2257. "Nexthop attribute\n"
  2258. "As-path attribute\n"
  2259. "Med attribute\n")
  2260. {
  2261. u_int16_t flags = PEER_FLAG_NEXTHOP_UNCHANGED;
  2262. if (strncmp (argv[1], "as-path", 1) == 0)
  2263. SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED);
  2264. else if (strncmp (argv[1], "med", 1) == 0)
  2265. SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED);
  2266. return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
  2267. bgp_node_safi (vty), flags);
  2268. }
  2269. DEFUN (neighbor_attr_unchanged4,
  2270. neighbor_attr_unchanged4_cmd,
  2271. NEIGHBOR_CMD2 "attribute-unchanged med (as-path|next-hop)",
  2272. NEIGHBOR_STR
  2273. NEIGHBOR_ADDR_STR2
  2274. "BGP attribute is propagated unchanged to this neighbor\n"
  2275. "Med attribute\n"
  2276. "As-path attribute\n"
  2277. "Nexthop attribute\n")
  2278. {
  2279. u_int16_t flags = PEER_FLAG_MED_UNCHANGED;
  2280. if (strncmp (argv[1], "as-path", 1) == 0)
  2281. SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED);
  2282. else if (strncmp (argv[1], "next-hop", 1) == 0)
  2283. SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED);
  2284. return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
  2285. bgp_node_safi (vty), flags);
  2286. }
  2287. ALIAS (neighbor_attr_unchanged,
  2288. neighbor_attr_unchanged5_cmd,
  2289. NEIGHBOR_CMD2 "attribute-unchanged as-path next-hop med",
  2290. NEIGHBOR_STR
  2291. NEIGHBOR_ADDR_STR2
  2292. "BGP attribute is propagated unchanged to this neighbor\n"
  2293. "As-path attribute\n"
  2294. "Nexthop attribute\n"
  2295. "Med attribute\n")
  2296. ALIAS (neighbor_attr_unchanged,
  2297. neighbor_attr_unchanged6_cmd,
  2298. NEIGHBOR_CMD2 "attribute-unchanged as-path med next-hop",
  2299. NEIGHBOR_STR
  2300. NEIGHBOR_ADDR_STR2
  2301. "BGP attribute is propagated unchanged to this neighbor\n"
  2302. "As-path attribute\n"
  2303. "Med attribute\n"
  2304. "Nexthop attribute\n")
  2305. ALIAS (neighbor_attr_unchanged,
  2306. neighbor_attr_unchanged7_cmd,
  2307. NEIGHBOR_CMD2 "attribute-unchanged next-hop med as-path",
  2308. NEIGHBOR_STR
  2309. NEIGHBOR_ADDR_STR2
  2310. "BGP attribute is propagated unchanged to this neighbor\n"
  2311. "Nexthop attribute\n"
  2312. "Med attribute\n"
  2313. "As-path attribute\n")
  2314. ALIAS (neighbor_attr_unchanged,
  2315. neighbor_attr_unchanged8_cmd,
  2316. NEIGHBOR_CMD2 "attribute-unchanged next-hop as-path med",
  2317. NEIGHBOR_STR
  2318. NEIGHBOR_ADDR_STR2
  2319. "BGP attribute is propagated unchanged to this neighbor\n"
  2320. "Nexthop attribute\n"
  2321. "As-path attribute\n"
  2322. "Med attribute\n")
  2323. ALIAS (neighbor_attr_unchanged,
  2324. neighbor_attr_unchanged9_cmd,
  2325. NEIGHBOR_CMD2 "attribute-unchanged med next-hop as-path",
  2326. NEIGHBOR_STR
  2327. NEIGHBOR_ADDR_STR2
  2328. "BGP attribute is propagated unchanged to this neighbor\n"
  2329. "Med attribute\n"
  2330. "Nexthop attribute\n"
  2331. "As-path attribute\n")
  2332. ALIAS (neighbor_attr_unchanged,
  2333. neighbor_attr_unchanged10_cmd,
  2334. NEIGHBOR_CMD2 "attribute-unchanged med as-path next-hop",
  2335. NEIGHBOR_STR
  2336. NEIGHBOR_ADDR_STR2
  2337. "BGP attribute is propagated unchanged to this neighbor\n"
  2338. "Med attribute\n"
  2339. "As-path attribute\n"
  2340. "Nexthop attribute\n")
  2341. DEFUN (no_neighbor_attr_unchanged,
  2342. no_neighbor_attr_unchanged_cmd,
  2343. NO_NEIGHBOR_CMD2 "attribute-unchanged",
  2344. NO_STR
  2345. NEIGHBOR_STR
  2346. NEIGHBOR_ADDR_STR2
  2347. "BGP attribute is propagated unchanged to this neighbor\n")
  2348. {
  2349. return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
  2350. bgp_node_safi (vty),
  2351. (PEER_FLAG_AS_PATH_UNCHANGED |
  2352. PEER_FLAG_NEXTHOP_UNCHANGED |
  2353. PEER_FLAG_MED_UNCHANGED));
  2354. }
  2355. DEFUN (no_neighbor_attr_unchanged1,
  2356. no_neighbor_attr_unchanged1_cmd,
  2357. NO_NEIGHBOR_CMD2 "attribute-unchanged (as-path|next-hop|med)",
  2358. NO_STR
  2359. NEIGHBOR_STR
  2360. NEIGHBOR_ADDR_STR2
  2361. "BGP attribute is propagated unchanged to this neighbor\n"
  2362. "As-path attribute\n"
  2363. "Nexthop attribute\n"
  2364. "Med attribute\n")
  2365. {
  2366. u_int16_t flags = 0;
  2367. if (strncmp (argv[1], "as-path", 1) == 0)
  2368. SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED);
  2369. else if (strncmp (argv[1], "next-hop", 1) == 0)
  2370. SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED);
  2371. else if (strncmp (argv[1], "med", 1) == 0)
  2372. SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED);
  2373. return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
  2374. bgp_node_safi (vty), flags);
  2375. }
  2376. DEFUN (no_neighbor_attr_unchanged2,
  2377. no_neighbor_attr_unchanged2_cmd,
  2378. NO_NEIGHBOR_CMD2 "attribute-unchanged as-path (next-hop|med)",
  2379. NO_STR
  2380. NEIGHBOR_STR
  2381. NEIGHBOR_ADDR_STR2
  2382. "BGP attribute is propagated unchanged to this neighbor\n"
  2383. "As-path attribute\n"
  2384. "Nexthop attribute\n"
  2385. "Med attribute\n")
  2386. {
  2387. u_int16_t flags = PEER_FLAG_AS_PATH_UNCHANGED;
  2388. if (strncmp (argv[1], "next-hop", 1) == 0)
  2389. SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED);
  2390. else if (strncmp (argv[1], "med", 1) == 0)
  2391. SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED);
  2392. return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
  2393. bgp_node_safi (vty), flags);
  2394. }
  2395. DEFUN (no_neighbor_attr_unchanged3,
  2396. no_neighbor_attr_unchanged3_cmd,
  2397. NO_NEIGHBOR_CMD2 "attribute-unchanged next-hop (as-path|med)",
  2398. NO_STR
  2399. NEIGHBOR_STR
  2400. NEIGHBOR_ADDR_STR2
  2401. "BGP attribute is propagated unchanged to this neighbor\n"
  2402. "Nexthop attribute\n"
  2403. "As-path attribute\n"
  2404. "Med attribute\n")
  2405. {
  2406. u_int16_t flags = PEER_FLAG_NEXTHOP_UNCHANGED;
  2407. if (strncmp (argv[1], "as-path", 1) == 0)
  2408. SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED);
  2409. else if (strncmp (argv[1], "med", 1) == 0)
  2410. SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED);
  2411. return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
  2412. bgp_node_safi (vty), flags);
  2413. }
  2414. DEFUN (no_neighbor_attr_unchanged4,
  2415. no_neighbor_attr_unchanged4_cmd,
  2416. NO_NEIGHBOR_CMD2 "attribute-unchanged med (as-path|next-hop)",
  2417. NO_STR
  2418. NEIGHBOR_STR
  2419. NEIGHBOR_ADDR_STR2
  2420. "BGP attribute is propagated unchanged to this neighbor\n"
  2421. "Med attribute\n"
  2422. "As-path attribute\n"
  2423. "Nexthop attribute\n")
  2424. {
  2425. u_int16_t flags = PEER_FLAG_MED_UNCHANGED;
  2426. if (strncmp (argv[1], "as-path", 1) == 0)
  2427. SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED);
  2428. else if (strncmp (argv[1], "next-hop", 1) == 0)
  2429. SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED);
  2430. return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
  2431. bgp_node_safi (vty), flags);
  2432. }
  2433. ALIAS (no_neighbor_attr_unchanged,
  2434. no_neighbor_attr_unchanged5_cmd,
  2435. NO_NEIGHBOR_CMD2 "attribute-unchanged as-path next-hop med",
  2436. NO_STR
  2437. NEIGHBOR_STR
  2438. NEIGHBOR_ADDR_STR2
  2439. "BGP attribute is propagated unchanged to this neighbor\n"
  2440. "As-path attribute\n"
  2441. "Nexthop attribute\n"
  2442. "Med attribute\n")
  2443. ALIAS (no_neighbor_attr_unchanged,
  2444. no_neighbor_attr_unchanged6_cmd,
  2445. NO_NEIGHBOR_CMD2 "attribute-unchanged as-path med next-hop",
  2446. NO_STR
  2447. NEIGHBOR_STR
  2448. NEIGHBOR_ADDR_STR2
  2449. "BGP attribute is propagated unchanged to this neighbor\n"
  2450. "As-path attribute\n"
  2451. "Med attribute\n"
  2452. "Nexthop attribute\n")
  2453. ALIAS (no_neighbor_attr_unchanged,
  2454. no_neighbor_attr_unchanged7_cmd,
  2455. NO_NEIGHBOR_CMD2 "attribute-unchanged next-hop med as-path",
  2456. NO_STR
  2457. NEIGHBOR_STR
  2458. NEIGHBOR_ADDR_STR2
  2459. "BGP attribute is propagated unchanged to this neighbor\n"
  2460. "Nexthop attribute\n"
  2461. "Med attribute\n"
  2462. "As-path attribute\n")
  2463. ALIAS (no_neighbor_attr_unchanged,
  2464. no_neighbor_attr_unchanged8_cmd,
  2465. NO_NEIGHBOR_CMD2 "attribute-unchanged next-hop as-path med",
  2466. NO_STR
  2467. NEIGHBOR_STR
  2468. NEIGHBOR_ADDR_STR2
  2469. "BGP attribute is propagated unchanged to this neighbor\n"
  2470. "Nexthop attribute\n"
  2471. "As-path attribute\n"
  2472. "Med attribute\n")
  2473. ALIAS (no_neighbor_attr_unchanged,
  2474. no_neighbor_attr_unchanged9_cmd,
  2475. NO_NEIGHBOR_CMD2 "attribute-unchanged med next-hop as-path",
  2476. NO_STR
  2477. NEIGHBOR_STR
  2478. NEIGHBOR_ADDR_STR2
  2479. "BGP attribute is propagated unchanged to this neighbor\n"
  2480. "Med attribute\n"
  2481. "Nexthop attribute\n"
  2482. "As-path attribute\n")
  2483. ALIAS (no_neighbor_attr_unchanged,
  2484. no_neighbor_attr_unchanged10_cmd,
  2485. NO_NEIGHBOR_CMD2 "attribute-unchanged med as-path next-hop",
  2486. NO_STR
  2487. NEIGHBOR_STR
  2488. NEIGHBOR_ADDR_STR2
  2489. "BGP attribute is propagated unchanged to this neighbor\n"
  2490. "Med attribute\n"
  2491. "As-path attribute\n"
  2492. "Nexthop attribute\n")
  2493. /* For old version Zebra compatibility. */
  2494. DEFUN_DEPRECATED (neighbor_transparent_as,
  2495. neighbor_transparent_as_cmd,
  2496. NEIGHBOR_CMD "transparent-as",
  2497. NEIGHBOR_STR
  2498. NEIGHBOR_ADDR_STR
  2499. "Do not append my AS number even peer is EBGP peer\n")
  2500. {
  2501. return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
  2502. bgp_node_safi (vty),
  2503. PEER_FLAG_AS_PATH_UNCHANGED);
  2504. }
  2505. DEFUN_DEPRECATED (neighbor_transparent_nexthop,
  2506. neighbor_transparent_nexthop_cmd,
  2507. NEIGHBOR_CMD "transparent-nexthop",
  2508. NEIGHBOR_STR
  2509. NEIGHBOR_ADDR_STR
  2510. "Do not change nexthop even peer is EBGP peer\n")
  2511. {
  2512. return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
  2513. bgp_node_safi (vty),
  2514. PEER_FLAG_NEXTHOP_UNCHANGED);
  2515. }
  2516. /* EBGP multihop configuration. */
  2517. static int
  2518. peer_ebgp_multihop_set_vty (struct vty *vty, const char *ip_str,
  2519. const char *ttl_str)
  2520. {
  2521. struct peer *peer;
  2522. unsigned int ttl;
  2523. peer = peer_and_group_lookup_vty (vty, ip_str);
  2524. if (! peer)
  2525. return CMD_WARNING;
  2526. if (! ttl_str)
  2527. ttl = TTL_MAX;
  2528. else
  2529. VTY_GET_INTEGER_RANGE ("TTL", ttl, ttl_str, 1, 255);
  2530. return bgp_vty_return (vty, peer_ebgp_multihop_set (peer, ttl));
  2531. }
  2532. static int
  2533. peer_ebgp_multihop_unset_vty (struct vty *vty, const char *ip_str)
  2534. {
  2535. struct peer *peer;
  2536. peer = peer_and_group_lookup_vty (vty, ip_str);
  2537. if (! peer)
  2538. return CMD_WARNING;
  2539. return bgp_vty_return (vty, peer_ebgp_multihop_unset (peer));
  2540. }
  2541. /* neighbor ebgp-multihop. */
  2542. DEFUN (neighbor_ebgp_multihop,
  2543. neighbor_ebgp_multihop_cmd,
  2544. NEIGHBOR_CMD2 "ebgp-multihop",
  2545. NEIGHBOR_STR
  2546. NEIGHBOR_ADDR_STR2
  2547. "Allow EBGP neighbors not on directly connected networks\n")
  2548. {
  2549. return peer_ebgp_multihop_set_vty (vty, argv[0], NULL);
  2550. }
  2551. DEFUN (neighbor_ebgp_multihop_ttl,
  2552. neighbor_ebgp_multihop_ttl_cmd,
  2553. NEIGHBOR_CMD2 "ebgp-multihop <1-255>",
  2554. NEIGHBOR_STR
  2555. NEIGHBOR_ADDR_STR2
  2556. "Allow EBGP neighbors not on directly connected networks\n"
  2557. "maximum hop count\n")
  2558. {
  2559. return peer_ebgp_multihop_set_vty (vty, argv[0], argv[1]);
  2560. }
  2561. DEFUN (no_neighbor_ebgp_multihop,
  2562. no_neighbor_ebgp_multihop_cmd,
  2563. NO_NEIGHBOR_CMD2 "ebgp-multihop",
  2564. NO_STR
  2565. NEIGHBOR_STR
  2566. NEIGHBOR_ADDR_STR2
  2567. "Allow EBGP neighbors not on directly connected networks\n")
  2568. {
  2569. return peer_ebgp_multihop_unset_vty (vty, argv[0]);
  2570. }
  2571. ALIAS (no_neighbor_ebgp_multihop,
  2572. no_neighbor_ebgp_multihop_ttl_cmd,
  2573. NO_NEIGHBOR_CMD2 "ebgp-multihop <1-255>",
  2574. NO_STR
  2575. NEIGHBOR_STR
  2576. NEIGHBOR_ADDR_STR2
  2577. "Allow EBGP neighbors not on directly connected networks\n"
  2578. "maximum hop count\n")
  2579. /* disable-connected-check */
  2580. DEFUN (neighbor_disable_connected_check,
  2581. neighbor_disable_connected_check_cmd,
  2582. NEIGHBOR_CMD2 "disable-connected-check",
  2583. NEIGHBOR_STR
  2584. NEIGHBOR_ADDR_STR2
  2585. "one-hop away EBGP peer using loopback address\n")
  2586. {
  2587. return peer_flag_set_vty (vty, argv[0], PEER_FLAG_DISABLE_CONNECTED_CHECK);
  2588. }
  2589. DEFUN (no_neighbor_disable_connected_check,
  2590. no_neighbor_disable_connected_check_cmd,
  2591. NO_NEIGHBOR_CMD2 "disable-connected-check",
  2592. NO_STR
  2593. NEIGHBOR_STR
  2594. NEIGHBOR_ADDR_STR2
  2595. "one-hop away EBGP peer using loopback address\n")
  2596. {
  2597. return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_DISABLE_CONNECTED_CHECK);
  2598. }
  2599. /* Enforce multihop. */
  2600. ALIAS (neighbor_disable_connected_check,
  2601. neighbor_enforce_multihop_cmd,
  2602. NEIGHBOR_CMD2 "enforce-multihop",
  2603. NEIGHBOR_STR
  2604. NEIGHBOR_ADDR_STR2
  2605. "Enforce EBGP neighbors perform multihop\n")
  2606. /* Enforce multihop. */
  2607. ALIAS (no_neighbor_disable_connected_check,
  2608. no_neighbor_enforce_multihop_cmd,
  2609. NO_NEIGHBOR_CMD2 "enforce-multihop",
  2610. NO_STR
  2611. NEIGHBOR_STR
  2612. NEIGHBOR_ADDR_STR2
  2613. "Enforce EBGP neighbors perform multihop\n")
  2614. DEFUN (neighbor_description,
  2615. neighbor_description_cmd,
  2616. NEIGHBOR_CMD2 "description .LINE",
  2617. NEIGHBOR_STR
  2618. NEIGHBOR_ADDR_STR2
  2619. "Neighbor specific description\n"
  2620. "Up to 80 characters describing this neighbor\n")
  2621. {
  2622. struct peer *peer;
  2623. char *str;
  2624. peer = peer_and_group_lookup_vty (vty, argv[0]);
  2625. if (! peer)
  2626. return CMD_WARNING;
  2627. if (argc == 1)
  2628. return CMD_SUCCESS;
  2629. str = argv_concat(argv, argc, 1);
  2630. peer_description_set (peer, str);
  2631. XFREE (MTYPE_TMP, str);
  2632. return CMD_SUCCESS;
  2633. }
  2634. DEFUN (no_neighbor_description,
  2635. no_neighbor_description_cmd,
  2636. NO_NEIGHBOR_CMD2 "description",
  2637. NO_STR
  2638. NEIGHBOR_STR
  2639. NEIGHBOR_ADDR_STR2
  2640. "Neighbor specific description\n")
  2641. {
  2642. struct peer *peer;
  2643. peer = peer_and_group_lookup_vty (vty, argv[0]);
  2644. if (! peer)
  2645. return CMD_WARNING;
  2646. peer_description_unset (peer);
  2647. return CMD_SUCCESS;
  2648. }
  2649. ALIAS (no_neighbor_description,
  2650. no_neighbor_description_val_cmd,
  2651. NO_NEIGHBOR_CMD2 "description .LINE",
  2652. NO_STR
  2653. NEIGHBOR_STR
  2654. NEIGHBOR_ADDR_STR2
  2655. "Neighbor specific description\n"
  2656. "Up to 80 characters describing this neighbor\n")
  2657. /* Neighbor update-source. */
  2658. static int
  2659. peer_update_source_vty (struct vty *vty, const char *peer_str,
  2660. const char *source_str)
  2661. {
  2662. struct peer *peer;
  2663. peer = peer_and_group_lookup_vty (vty, peer_str);
  2664. if (! peer)
  2665. return CMD_WARNING;
  2666. if (source_str)
  2667. {
  2668. union sockunion su;
  2669. int ret = str2sockunion (source_str, &su);
  2670. if (ret == 0)
  2671. peer_update_source_addr_set (peer, &su);
  2672. else
  2673. peer_update_source_if_set (peer, source_str);
  2674. }
  2675. else
  2676. peer_update_source_unset (peer);
  2677. return CMD_SUCCESS;
  2678. }
  2679. #define BGP_UPDATE_SOURCE_STR "(A.B.C.D|X:X::X:X|WORD)"
  2680. #define BGP_UPDATE_SOURCE_HELP_STR \
  2681. "IPv4 address\n" \
  2682. "IPv6 address\n" \
  2683. "Interface name (requires zebra to be running)\n"
  2684. DEFUN (neighbor_update_source,
  2685. neighbor_update_source_cmd,
  2686. NEIGHBOR_CMD2 "update-source " BGP_UPDATE_SOURCE_STR,
  2687. NEIGHBOR_STR
  2688. NEIGHBOR_ADDR_STR2
  2689. "Source of routing updates\n"
  2690. BGP_UPDATE_SOURCE_HELP_STR)
  2691. {
  2692. return peer_update_source_vty (vty, argv[0], argv[1]);
  2693. }
  2694. DEFUN (no_neighbor_update_source,
  2695. no_neighbor_update_source_cmd,
  2696. NO_NEIGHBOR_CMD2 "update-source",
  2697. NO_STR
  2698. NEIGHBOR_STR
  2699. NEIGHBOR_ADDR_STR2
  2700. "Source of routing updates\n")
  2701. {
  2702. return peer_update_source_vty (vty, argv[0], NULL);
  2703. }
  2704. static int
  2705. peer_default_originate_set_vty (struct vty *vty, const char *peer_str,
  2706. afi_t afi, safi_t safi,
  2707. const char *rmap, int set)
  2708. {
  2709. int ret;
  2710. struct peer *peer;
  2711. peer = peer_and_group_lookup_vty (vty, peer_str);
  2712. if (! peer)
  2713. return CMD_WARNING;
  2714. if (set)
  2715. ret = peer_default_originate_set (peer, afi, safi, rmap);
  2716. else
  2717. ret = peer_default_originate_unset (peer, afi, safi);
  2718. return bgp_vty_return (vty, ret);
  2719. }
  2720. /* neighbor default-originate. */
  2721. DEFUN (neighbor_default_originate,
  2722. neighbor_default_originate_cmd,
  2723. NEIGHBOR_CMD2 "default-originate",
  2724. NEIGHBOR_STR
  2725. NEIGHBOR_ADDR_STR2
  2726. "Originate default route to this neighbor\n")
  2727. {
  2728. return peer_default_originate_set_vty (vty, argv[0], bgp_node_afi (vty),
  2729. bgp_node_safi (vty), NULL, 1);
  2730. }
  2731. DEFUN (neighbor_default_originate_rmap,
  2732. neighbor_default_originate_rmap_cmd,
  2733. NEIGHBOR_CMD2 "default-originate route-map WORD",
  2734. NEIGHBOR_STR
  2735. NEIGHBOR_ADDR_STR2
  2736. "Originate default route to this neighbor\n"
  2737. "Route-map to specify criteria to originate default\n"
  2738. "route-map name\n")
  2739. {
  2740. return peer_default_originate_set_vty (vty, argv[0], bgp_node_afi (vty),
  2741. bgp_node_safi (vty), argv[1], 1);
  2742. }
  2743. DEFUN (no_neighbor_default_originate,
  2744. no_neighbor_default_originate_cmd,
  2745. NO_NEIGHBOR_CMD2 "default-originate",
  2746. NO_STR
  2747. NEIGHBOR_STR
  2748. NEIGHBOR_ADDR_STR2
  2749. "Originate default route to this neighbor\n")
  2750. {
  2751. return peer_default_originate_set_vty (vty, argv[0], bgp_node_afi (vty),
  2752. bgp_node_safi (vty), NULL, 0);
  2753. }
  2754. ALIAS (no_neighbor_default_originate,
  2755. no_neighbor_default_originate_rmap_cmd,
  2756. NO_NEIGHBOR_CMD2 "default-originate route-map WORD",
  2757. NO_STR
  2758. NEIGHBOR_STR
  2759. NEIGHBOR_ADDR_STR2
  2760. "Originate default route to this neighbor\n"
  2761. "Route-map to specify criteria to originate default\n"
  2762. "route-map name\n")
  2763. /* Set neighbor's BGP port. */
  2764. static int
  2765. peer_port_vty (struct vty *vty, const char *ip_str, int afi,
  2766. const char *port_str)
  2767. {
  2768. struct peer *peer;
  2769. u_int16_t port;
  2770. struct servent *sp;
  2771. peer = peer_lookup_vty (vty, ip_str);
  2772. if (! peer)
  2773. return CMD_WARNING;
  2774. if (! port_str)
  2775. {
  2776. sp = getservbyname ("bgp", "tcp");
  2777. port = (sp == NULL) ? BGP_PORT_DEFAULT : ntohs (sp->s_port);
  2778. }
  2779. else
  2780. {
  2781. VTY_GET_INTEGER("port", port, port_str);
  2782. }
  2783. peer_port_set (peer, port);
  2784. return CMD_SUCCESS;
  2785. }
  2786. /* Set specified peer's BGP port. */
  2787. DEFUN (neighbor_port,
  2788. neighbor_port_cmd,
  2789. NEIGHBOR_CMD "port <0-65535>",
  2790. NEIGHBOR_STR
  2791. NEIGHBOR_ADDR_STR
  2792. "Neighbor's BGP port\n"
  2793. "TCP port number\n")
  2794. {
  2795. return peer_port_vty (vty, argv[0], AFI_IP, argv[1]);
  2796. }
  2797. DEFUN (no_neighbor_port,
  2798. no_neighbor_port_cmd,
  2799. NO_NEIGHBOR_CMD "port",
  2800. NO_STR
  2801. NEIGHBOR_STR
  2802. NEIGHBOR_ADDR_STR
  2803. "Neighbor's BGP port\n")
  2804. {
  2805. return peer_port_vty (vty, argv[0], AFI_IP, NULL);
  2806. }
  2807. ALIAS (no_neighbor_port,
  2808. no_neighbor_port_val_cmd,
  2809. NO_NEIGHBOR_CMD "port <0-65535>",
  2810. NO_STR
  2811. NEIGHBOR_STR
  2812. NEIGHBOR_ADDR_STR
  2813. "Neighbor's BGP port\n"
  2814. "TCP port number\n")
  2815. /* neighbor weight. */
  2816. static int
  2817. peer_weight_set_vty (struct vty *vty, const char *ip_str,
  2818. const char *weight_str)
  2819. {
  2820. struct peer *peer;
  2821. unsigned long weight;
  2822. peer = peer_and_group_lookup_vty (vty, ip_str);
  2823. if (! peer)
  2824. return CMD_WARNING;
  2825. VTY_GET_INTEGER_RANGE("weight", weight, weight_str, 0, 65535);
  2826. return bgp_vty_return (vty, peer_weight_set (peer, weight));
  2827. }
  2828. static int
  2829. peer_weight_unset_vty (struct vty *vty, const char *ip_str)
  2830. {
  2831. struct peer *peer;
  2832. peer = peer_and_group_lookup_vty (vty, ip_str);
  2833. if (! peer)
  2834. return CMD_WARNING;
  2835. return bgp_vty_return (vty, peer_weight_unset (peer));
  2836. }
  2837. DEFUN (neighbor_weight,
  2838. neighbor_weight_cmd,
  2839. NEIGHBOR_CMD2 "weight <0-65535>",
  2840. NEIGHBOR_STR
  2841. NEIGHBOR_ADDR_STR2
  2842. "Set default weight for routes from this neighbor\n"
  2843. "default weight\n")
  2844. {
  2845. return peer_weight_set_vty (vty, argv[0], argv[1]);
  2846. }
  2847. DEFUN (no_neighbor_weight,
  2848. no_neighbor_weight_cmd,
  2849. NO_NEIGHBOR_CMD2 "weight",
  2850. NO_STR
  2851. NEIGHBOR_STR
  2852. NEIGHBOR_ADDR_STR2
  2853. "Set default weight for routes from this neighbor\n")
  2854. {
  2855. return peer_weight_unset_vty (vty, argv[0]);
  2856. }
  2857. ALIAS (no_neighbor_weight,
  2858. no_neighbor_weight_val_cmd,
  2859. NO_NEIGHBOR_CMD2 "weight <0-65535>",
  2860. NO_STR
  2861. NEIGHBOR_STR
  2862. NEIGHBOR_ADDR_STR2
  2863. "Set default weight for routes from this neighbor\n"
  2864. "default weight\n")
  2865. /* Override capability negotiation. */
  2866. DEFUN (neighbor_override_capability,
  2867. neighbor_override_capability_cmd,
  2868. NEIGHBOR_CMD2 "override-capability",
  2869. NEIGHBOR_STR
  2870. NEIGHBOR_ADDR_STR2
  2871. "Override capability negotiation result\n")
  2872. {
  2873. return peer_flag_set_vty (vty, argv[0], PEER_FLAG_OVERRIDE_CAPABILITY);
  2874. }
  2875. DEFUN (no_neighbor_override_capability,
  2876. no_neighbor_override_capability_cmd,
  2877. NO_NEIGHBOR_CMD2 "override-capability",
  2878. NO_STR
  2879. NEIGHBOR_STR
  2880. NEIGHBOR_ADDR_STR2
  2881. "Override capability negotiation result\n")
  2882. {
  2883. return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_OVERRIDE_CAPABILITY);
  2884. }
  2885. DEFUN (neighbor_strict_capability,
  2886. neighbor_strict_capability_cmd,
  2887. NEIGHBOR_CMD "strict-capability-match",
  2888. NEIGHBOR_STR
  2889. NEIGHBOR_ADDR_STR
  2890. "Strict capability negotiation match\n")
  2891. {
  2892. return peer_flag_set_vty (vty, argv[0], PEER_FLAG_STRICT_CAP_MATCH);
  2893. }
  2894. DEFUN (no_neighbor_strict_capability,
  2895. no_neighbor_strict_capability_cmd,
  2896. NO_NEIGHBOR_CMD "strict-capability-match",
  2897. NO_STR
  2898. NEIGHBOR_STR
  2899. NEIGHBOR_ADDR_STR
  2900. "Strict capability negotiation match\n")
  2901. {
  2902. return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_STRICT_CAP_MATCH);
  2903. }
  2904. static int
  2905. peer_timers_set_vty (struct vty *vty, const char *ip_str,
  2906. const char *keep_str, const char *hold_str)
  2907. {
  2908. int ret;
  2909. struct peer *peer;
  2910. u_int32_t keepalive;
  2911. u_int32_t holdtime;
  2912. peer = peer_and_group_lookup_vty (vty, ip_str);
  2913. if (! peer)
  2914. return CMD_WARNING;
  2915. VTY_GET_INTEGER_RANGE ("Keepalive", keepalive, keep_str, 0, 65535);
  2916. VTY_GET_INTEGER_RANGE ("Holdtime", holdtime, hold_str, 0, 65535);
  2917. ret = peer_timers_set (peer, keepalive, holdtime);
  2918. return bgp_vty_return (vty, ret);
  2919. }
  2920. static int
  2921. peer_timers_unset_vty (struct vty *vty, const char *ip_str)
  2922. {
  2923. int ret;
  2924. struct peer *peer;
  2925. peer = peer_lookup_vty (vty, ip_str);
  2926. if (! peer)
  2927. return CMD_WARNING;
  2928. ret = peer_timers_unset (peer);
  2929. return bgp_vty_return (vty, ret);
  2930. }
  2931. DEFUN (neighbor_timers,
  2932. neighbor_timers_cmd,
  2933. NEIGHBOR_CMD2 "timers <0-65535> <0-65535>",
  2934. NEIGHBOR_STR
  2935. NEIGHBOR_ADDR_STR2
  2936. "BGP per neighbor timers\n"
  2937. "Keepalive interval\n"
  2938. "Holdtime\n")
  2939. {
  2940. return peer_timers_set_vty (vty, argv[0], argv[1], argv[2]);
  2941. }
  2942. DEFUN (no_neighbor_timers,
  2943. no_neighbor_timers_cmd,
  2944. NO_NEIGHBOR_CMD2 "timers",
  2945. NO_STR
  2946. NEIGHBOR_STR
  2947. NEIGHBOR_ADDR_STR2
  2948. "BGP per neighbor timers\n")
  2949. {
  2950. return peer_timers_unset_vty (vty, argv[0]);
  2951. }
  2952. static int
  2953. peer_timers_connect_set_vty (struct vty *vty, const char *ip_str,
  2954. const char *time_str)
  2955. {
  2956. struct peer *peer;
  2957. u_int32_t connect;
  2958. peer = peer_and_group_lookup_vty (vty, ip_str);
  2959. if (! peer)
  2960. return CMD_WARNING;
  2961. VTY_GET_INTEGER_RANGE ("Connect time", connect, time_str, 0, 65535);
  2962. return bgp_vty_return (vty, peer_timers_connect_set (peer, connect));
  2963. }
  2964. static int
  2965. peer_timers_connect_unset_vty (struct vty *vty, const char *ip_str)
  2966. {
  2967. struct peer *peer;
  2968. peer = peer_and_group_lookup_vty (vty, ip_str);
  2969. if (! peer)
  2970. return CMD_WARNING;
  2971. return bgp_vty_return (vty, peer_timers_connect_unset (peer));
  2972. }
  2973. DEFUN (neighbor_timers_connect,
  2974. neighbor_timers_connect_cmd,
  2975. NEIGHBOR_CMD2 "timers connect <1-65535>",
  2976. NEIGHBOR_STR
  2977. NEIGHBOR_ADDR_STR2
  2978. "BGP per neighbor timers\n"
  2979. "BGP connect timer\n"
  2980. "Connect timer\n")
  2981. {
  2982. return peer_timers_connect_set_vty (vty, argv[0], argv[1]);
  2983. }
  2984. DEFUN (no_neighbor_timers_connect,
  2985. no_neighbor_timers_connect_cmd,
  2986. NO_NEIGHBOR_CMD2 "timers connect",
  2987. NO_STR
  2988. NEIGHBOR_STR
  2989. NEIGHBOR_ADDR_STR2
  2990. "BGP per neighbor timers\n"
  2991. "BGP connect timer\n")
  2992. {
  2993. return peer_timers_connect_unset_vty (vty, argv[0]);
  2994. }
  2995. ALIAS (no_neighbor_timers_connect,
  2996. no_neighbor_timers_connect_val_cmd,
  2997. NO_NEIGHBOR_CMD2 "timers connect <1-65535>",
  2998. NO_STR
  2999. NEIGHBOR_STR
  3000. NEIGHBOR_ADDR_STR2
  3001. "BGP per neighbor timers\n"
  3002. "BGP connect timer\n"
  3003. "Connect timer\n")
  3004. static int
  3005. peer_advertise_interval_vty (struct vty *vty, const char *ip_str,
  3006. const char *time_str, int set)
  3007. {
  3008. int ret;
  3009. struct peer *peer;
  3010. u_int32_t routeadv = 0;
  3011. peer = peer_and_group_lookup_vty (vty, ip_str);
  3012. if (! peer)
  3013. return CMD_WARNING;
  3014. if (time_str)
  3015. VTY_GET_INTEGER_RANGE ("advertise interval", routeadv, time_str, 0, 600);
  3016. if (set)
  3017. ret = peer_advertise_interval_set (peer, routeadv);
  3018. else
  3019. ret = peer_advertise_interval_unset (peer);
  3020. return bgp_vty_return (vty, ret);
  3021. }
  3022. DEFUN (neighbor_advertise_interval,
  3023. neighbor_advertise_interval_cmd,
  3024. NEIGHBOR_CMD2 "advertisement-interval <0-600>",
  3025. NEIGHBOR_STR
  3026. NEIGHBOR_ADDR_STR2
  3027. "Minimum interval between sending BGP routing updates\n"
  3028. "time in seconds\n")
  3029. {
  3030. return peer_advertise_interval_vty (vty, argv[0], argv[1], 1);
  3031. }
  3032. DEFUN (no_neighbor_advertise_interval,
  3033. no_neighbor_advertise_interval_cmd,
  3034. NO_NEIGHBOR_CMD2 "advertisement-interval",
  3035. NO_STR
  3036. NEIGHBOR_STR
  3037. NEIGHBOR_ADDR_STR2
  3038. "Minimum interval between sending BGP routing updates\n")
  3039. {
  3040. return peer_advertise_interval_vty (vty, argv[0], NULL, 0);
  3041. }
  3042. ALIAS (no_neighbor_advertise_interval,
  3043. no_neighbor_advertise_interval_val_cmd,
  3044. NO_NEIGHBOR_CMD2 "advertisement-interval <0-600>",
  3045. NO_STR
  3046. NEIGHBOR_STR
  3047. NEIGHBOR_ADDR_STR2
  3048. "Minimum interval between sending BGP routing updates\n"
  3049. "time in seconds\n")
  3050. /* neighbor interface */
  3051. static int
  3052. peer_interface_vty (struct vty *vty, const char *ip_str, const char *str)
  3053. {
  3054. int ret;
  3055. struct peer *peer;
  3056. peer = peer_lookup_vty (vty, ip_str);
  3057. if (! peer)
  3058. return CMD_WARNING;
  3059. if (str)
  3060. ret = peer_interface_set (peer, str);
  3061. else
  3062. ret = peer_interface_unset (peer);
  3063. return bgp_vty_return (vty, ret);
  3064. }
  3065. DEFUN (neighbor_interface,
  3066. neighbor_interface_cmd,
  3067. NEIGHBOR_CMD "interface WORD",
  3068. NEIGHBOR_STR
  3069. NEIGHBOR_ADDR_STR
  3070. "Interface\n"
  3071. "Interface name\n")
  3072. {
  3073. return peer_interface_vty (vty, argv[0], argv[1]);
  3074. }
  3075. DEFUN (no_neighbor_interface,
  3076. no_neighbor_interface_cmd,
  3077. NO_NEIGHBOR_CMD "interface WORD",
  3078. NO_STR
  3079. NEIGHBOR_STR
  3080. NEIGHBOR_ADDR_STR
  3081. "Interface\n"
  3082. "Interface name\n")
  3083. {
  3084. return peer_interface_vty (vty, argv[0], NULL);
  3085. }
  3086. /* Set distribute list to the peer. */
  3087. static int
  3088. peer_distribute_set_vty (struct vty *vty, const char *ip_str,
  3089. afi_t afi, safi_t safi,
  3090. const char *name_str, const char *direct_str)
  3091. {
  3092. int ret;
  3093. struct peer *peer;
  3094. int direct = FILTER_IN;
  3095. peer = peer_and_group_lookup_vty (vty, ip_str);
  3096. if (! peer)
  3097. return CMD_WARNING;
  3098. /* Check filter direction. */
  3099. if (strncmp (direct_str, "i", 1) == 0)
  3100. direct = FILTER_IN;
  3101. else if (strncmp (direct_str, "o", 1) == 0)
  3102. direct = FILTER_OUT;
  3103. ret = peer_distribute_set (peer, afi, safi, direct, name_str);
  3104. return bgp_vty_return (vty, ret);
  3105. }
  3106. static int
  3107. peer_distribute_unset_vty (struct vty *vty, const char *ip_str, afi_t afi,
  3108. safi_t safi, const char *direct_str)
  3109. {
  3110. int ret;
  3111. struct peer *peer;
  3112. int direct = FILTER_IN;
  3113. peer = peer_and_group_lookup_vty (vty, ip_str);
  3114. if (! peer)
  3115. return CMD_WARNING;
  3116. /* Check filter direction. */
  3117. if (strncmp (direct_str, "i", 1) == 0)
  3118. direct = FILTER_IN;
  3119. else if (strncmp (direct_str, "o", 1) == 0)
  3120. direct = FILTER_OUT;
  3121. ret = peer_distribute_unset (peer, afi, safi, direct);
  3122. return bgp_vty_return (vty, ret);
  3123. }
  3124. DEFUN (neighbor_distribute_list,
  3125. neighbor_distribute_list_cmd,
  3126. NEIGHBOR_CMD2 "distribute-list (<1-199>|<1300-2699>|WORD) (in|out)",
  3127. NEIGHBOR_STR
  3128. NEIGHBOR_ADDR_STR2
  3129. "Filter updates to/from this neighbor\n"
  3130. "IP access-list number\n"
  3131. "IP access-list number (expanded range)\n"
  3132. "IP Access-list name\n"
  3133. "Filter incoming updates\n"
  3134. "Filter outgoing updates\n")
  3135. {
  3136. return peer_distribute_set_vty (vty, argv[0], bgp_node_afi (vty),
  3137. bgp_node_safi (vty), argv[1], argv[2]);
  3138. }
  3139. DEFUN (no_neighbor_distribute_list,
  3140. no_neighbor_distribute_list_cmd,
  3141. NO_NEIGHBOR_CMD2 "distribute-list (<1-199>|<1300-2699>|WORD) (in|out)",
  3142. NO_STR
  3143. NEIGHBOR_STR
  3144. NEIGHBOR_ADDR_STR2
  3145. "Filter updates to/from this neighbor\n"
  3146. "IP access-list number\n"
  3147. "IP access-list number (expanded range)\n"
  3148. "IP Access-list name\n"
  3149. "Filter incoming updates\n"
  3150. "Filter outgoing updates\n")
  3151. {
  3152. return peer_distribute_unset_vty (vty, argv[0], bgp_node_afi (vty),
  3153. bgp_node_safi (vty), argv[2]);
  3154. }
  3155. /* Set prefix list to the peer. */
  3156. static int
  3157. peer_prefix_list_set_vty (struct vty *vty, const char *ip_str, afi_t afi,
  3158. safi_t safi, const char *name_str,
  3159. const char *direct_str)
  3160. {
  3161. int ret;
  3162. struct peer *peer;
  3163. int direct = FILTER_IN;
  3164. peer = peer_and_group_lookup_vty (vty, ip_str);
  3165. if (! peer)
  3166. return CMD_WARNING;
  3167. /* Check filter direction. */
  3168. if (strncmp (direct_str, "i", 1) == 0)
  3169. direct = FILTER_IN;
  3170. else if (strncmp (direct_str, "o", 1) == 0)
  3171. direct = FILTER_OUT;
  3172. ret = peer_prefix_list_set (peer, afi, safi, direct, name_str);
  3173. return bgp_vty_return (vty, ret);
  3174. }
  3175. static int
  3176. peer_prefix_list_unset_vty (struct vty *vty, const char *ip_str, afi_t afi,
  3177. safi_t safi, const char *direct_str)
  3178. {
  3179. int ret;
  3180. struct peer *peer;
  3181. int direct = FILTER_IN;
  3182. peer = peer_and_group_lookup_vty (vty, ip_str);
  3183. if (! peer)
  3184. return CMD_WARNING;
  3185. /* Check filter direction. */
  3186. if (strncmp (direct_str, "i", 1) == 0)
  3187. direct = FILTER_IN;
  3188. else if (strncmp (direct_str, "o", 1) == 0)
  3189. direct = FILTER_OUT;
  3190. ret = peer_prefix_list_unset (peer, afi, safi, direct);
  3191. return bgp_vty_return (vty, ret);
  3192. }
  3193. DEFUN (neighbor_prefix_list,
  3194. neighbor_prefix_list_cmd,
  3195. NEIGHBOR_CMD2 "prefix-list WORD (in|out)",
  3196. NEIGHBOR_STR
  3197. NEIGHBOR_ADDR_STR2
  3198. "Filter updates to/from this neighbor\n"
  3199. "Name of a prefix list\n"
  3200. "Filter incoming updates\n"
  3201. "Filter outgoing updates\n")
  3202. {
  3203. return peer_prefix_list_set_vty (vty, argv[0], bgp_node_afi (vty),
  3204. bgp_node_safi (vty), argv[1], argv[2]);
  3205. }
  3206. DEFUN (no_neighbor_prefix_list,
  3207. no_neighbor_prefix_list_cmd,
  3208. NO_NEIGHBOR_CMD2 "prefix-list WORD (in|out)",
  3209. NO_STR
  3210. NEIGHBOR_STR
  3211. NEIGHBOR_ADDR_STR2
  3212. "Filter updates to/from this neighbor\n"
  3213. "Name of a prefix list\n"
  3214. "Filter incoming updates\n"
  3215. "Filter outgoing updates\n")
  3216. {
  3217. return peer_prefix_list_unset_vty (vty, argv[0], bgp_node_afi (vty),
  3218. bgp_node_safi (vty), argv[2]);
  3219. }
  3220. static int
  3221. peer_aslist_set_vty (struct vty *vty, const char *ip_str,
  3222. afi_t afi, safi_t safi,
  3223. const char *name_str, const char *direct_str)
  3224. {
  3225. int ret;
  3226. struct peer *peer;
  3227. int direct = FILTER_IN;
  3228. peer = peer_and_group_lookup_vty (vty, ip_str);
  3229. if (! peer)
  3230. return CMD_WARNING;
  3231. /* Check filter direction. */
  3232. if (strncmp (direct_str, "i", 1) == 0)
  3233. direct = FILTER_IN;
  3234. else if (strncmp (direct_str, "o", 1) == 0)
  3235. direct = FILTER_OUT;
  3236. ret = peer_aslist_set (peer, afi, safi, direct, name_str);
  3237. return bgp_vty_return (vty, ret);
  3238. }
  3239. static int
  3240. peer_aslist_unset_vty (struct vty *vty, const char *ip_str,
  3241. afi_t afi, safi_t safi,
  3242. const char *direct_str)
  3243. {
  3244. int ret;
  3245. struct peer *peer;
  3246. int direct = FILTER_IN;
  3247. peer = peer_and_group_lookup_vty (vty, ip_str);
  3248. if (! peer)
  3249. return CMD_WARNING;
  3250. /* Check filter direction. */
  3251. if (strncmp (direct_str, "i", 1) == 0)
  3252. direct = FILTER_IN;
  3253. else if (strncmp (direct_str, "o", 1) == 0)
  3254. direct = FILTER_OUT;
  3255. ret = peer_aslist_unset (peer, afi, safi, direct);
  3256. return bgp_vty_return (vty, ret);
  3257. }
  3258. DEFUN (neighbor_filter_list,
  3259. neighbor_filter_list_cmd,
  3260. NEIGHBOR_CMD2 "filter-list WORD (in|out)",
  3261. NEIGHBOR_STR
  3262. NEIGHBOR_ADDR_STR2
  3263. "Establish BGP filters\n"
  3264. "AS path access-list name\n"
  3265. "Filter incoming routes\n"
  3266. "Filter outgoing routes\n")
  3267. {
  3268. return peer_aslist_set_vty (vty, argv[0], bgp_node_afi (vty),
  3269. bgp_node_safi (vty), argv[1], argv[2]);
  3270. }
  3271. DEFUN (no_neighbor_filter_list,
  3272. no_neighbor_filter_list_cmd,
  3273. NO_NEIGHBOR_CMD2 "filter-list WORD (in|out)",
  3274. NO_STR
  3275. NEIGHBOR_STR
  3276. NEIGHBOR_ADDR_STR2
  3277. "Establish BGP filters\n"
  3278. "AS path access-list name\n"
  3279. "Filter incoming routes\n"
  3280. "Filter outgoing routes\n")
  3281. {
  3282. return peer_aslist_unset_vty (vty, argv[0], bgp_node_afi (vty),
  3283. bgp_node_safi (vty), argv[2]);
  3284. }
  3285. /* Set route-map to the peer. */
  3286. static int
  3287. peer_route_map_set_vty (struct vty *vty, const char *ip_str,
  3288. afi_t afi, safi_t safi,
  3289. const char *name_str, const char *direct_str)
  3290. {
  3291. int ret;
  3292. struct peer *peer;
  3293. int direct = RMAP_IN;
  3294. peer = peer_and_group_lookup_vty (vty, ip_str);
  3295. if (! peer)
  3296. return CMD_WARNING;
  3297. /* Check filter direction. */
  3298. if (strncmp (direct_str, "in", 2) == 0)
  3299. direct = RMAP_IN;
  3300. else if (strncmp (direct_str, "o", 1) == 0)
  3301. direct = RMAP_OUT;
  3302. else if (strncmp (direct_str, "im", 2) == 0)
  3303. direct = RMAP_IMPORT;
  3304. else if (strncmp (direct_str, "e", 1) == 0)
  3305. direct = RMAP_EXPORT;
  3306. ret = peer_route_map_set (peer, afi, safi, direct, name_str);
  3307. return bgp_vty_return (vty, ret);
  3308. }
  3309. static int
  3310. peer_route_map_unset_vty (struct vty *vty, const char *ip_str, afi_t afi,
  3311. safi_t safi, const char *direct_str)
  3312. {
  3313. int ret;
  3314. struct peer *peer;
  3315. int direct = RMAP_IN;
  3316. peer = peer_and_group_lookup_vty (vty, ip_str);
  3317. if (! peer)
  3318. return CMD_WARNING;
  3319. /* Check filter direction. */
  3320. if (strncmp (direct_str, "in", 2) == 0)
  3321. direct = RMAP_IN;
  3322. else if (strncmp (direct_str, "o", 1) == 0)
  3323. direct = RMAP_OUT;
  3324. else if (strncmp (direct_str, "im", 2) == 0)
  3325. direct = RMAP_IMPORT;
  3326. else if (strncmp (direct_str, "e", 1) == 0)
  3327. direct = RMAP_EXPORT;
  3328. ret = peer_route_map_unset (peer, afi, safi, direct);
  3329. return bgp_vty_return (vty, ret);
  3330. }
  3331. DEFUN (neighbor_route_map,
  3332. neighbor_route_map_cmd,
  3333. NEIGHBOR_CMD2 "route-map WORD (in|out|import|export)",
  3334. NEIGHBOR_STR
  3335. NEIGHBOR_ADDR_STR2
  3336. "Apply route map to neighbor\n"
  3337. "Name of route map\n"
  3338. "Apply map to incoming routes\n"
  3339. "Apply map to outbound routes\n"
  3340. "Apply map to routes going into a Route-Server client's table\n"
  3341. "Apply map to routes coming from a Route-Server client")
  3342. {
  3343. return peer_route_map_set_vty (vty, argv[0], bgp_node_afi (vty),
  3344. bgp_node_safi (vty), argv[1], argv[2]);
  3345. }
  3346. DEFUN (no_neighbor_route_map,
  3347. no_neighbor_route_map_cmd,
  3348. NO_NEIGHBOR_CMD2 "route-map WORD (in|out|import|export)",
  3349. NO_STR
  3350. NEIGHBOR_STR
  3351. NEIGHBOR_ADDR_STR2
  3352. "Apply route map to neighbor\n"
  3353. "Name of route map\n"
  3354. "Apply map to incoming routes\n"
  3355. "Apply map to outbound routes\n"
  3356. "Apply map to routes going into a Route-Server client's table\n"
  3357. "Apply map to routes coming from a Route-Server client")
  3358. {
  3359. return peer_route_map_unset_vty (vty, argv[0], bgp_node_afi (vty),
  3360. bgp_node_safi (vty), argv[2]);
  3361. }
  3362. /* Set unsuppress-map to the peer. */
  3363. static int
  3364. peer_unsuppress_map_set_vty (struct vty *vty, const char *ip_str, afi_t afi,
  3365. safi_t safi, const char *name_str)
  3366. {
  3367. int ret;
  3368. struct peer *peer;
  3369. peer = peer_and_group_lookup_vty (vty, ip_str);
  3370. if (! peer)
  3371. return CMD_WARNING;
  3372. ret = peer_unsuppress_map_set (peer, afi, safi, name_str);
  3373. return bgp_vty_return (vty, ret);
  3374. }
  3375. /* Unset route-map from the peer. */
  3376. static int
  3377. peer_unsuppress_map_unset_vty (struct vty *vty, const char *ip_str, afi_t afi,
  3378. safi_t safi)
  3379. {
  3380. int ret;
  3381. struct peer *peer;
  3382. peer = peer_and_group_lookup_vty (vty, ip_str);
  3383. if (! peer)
  3384. return CMD_WARNING;
  3385. ret = peer_unsuppress_map_unset (peer, afi, safi);
  3386. return bgp_vty_return (vty, ret);
  3387. }
  3388. DEFUN (neighbor_unsuppress_map,
  3389. neighbor_unsuppress_map_cmd,
  3390. NEIGHBOR_CMD2 "unsuppress-map WORD",
  3391. NEIGHBOR_STR
  3392. NEIGHBOR_ADDR_STR2
  3393. "Route-map to selectively unsuppress suppressed routes\n"
  3394. "Name of route map\n")
  3395. {
  3396. return peer_unsuppress_map_set_vty (vty, argv[0], bgp_node_afi (vty),
  3397. bgp_node_safi (vty), argv[1]);
  3398. }
  3399. DEFUN (no_neighbor_unsuppress_map,
  3400. no_neighbor_unsuppress_map_cmd,
  3401. NO_NEIGHBOR_CMD2 "unsuppress-map WORD",
  3402. NO_STR
  3403. NEIGHBOR_STR
  3404. NEIGHBOR_ADDR_STR2
  3405. "Route-map to selectively unsuppress suppressed routes\n"
  3406. "Name of route map\n")
  3407. {
  3408. return peer_unsuppress_map_unset_vty (vty, argv[0], bgp_node_afi (vty),
  3409. bgp_node_safi (vty));
  3410. }
  3411. static int
  3412. peer_maximum_prefix_set_vty (struct vty *vty, const char *ip_str, afi_t afi,
  3413. safi_t safi, const char *num_str,
  3414. const char *threshold_str, int warning,
  3415. const char *restart_str)
  3416. {
  3417. int ret;
  3418. struct peer *peer;
  3419. u_int32_t max;
  3420. u_char threshold;
  3421. u_int16_t restart;
  3422. peer = peer_and_group_lookup_vty (vty, ip_str);
  3423. if (! peer)
  3424. return CMD_WARNING;
  3425. VTY_GET_INTEGER ("maximum number", max, num_str);
  3426. if (threshold_str)
  3427. threshold = atoi (threshold_str);
  3428. else
  3429. threshold = MAXIMUM_PREFIX_THRESHOLD_DEFAULT;
  3430. if (restart_str)
  3431. restart = atoi (restart_str);
  3432. else
  3433. restart = 0;
  3434. ret = peer_maximum_prefix_set (peer, afi, safi, max, threshold, warning, restart);
  3435. return bgp_vty_return (vty, ret);
  3436. }
  3437. static int
  3438. peer_maximum_prefix_unset_vty (struct vty *vty, const char *ip_str, afi_t afi,
  3439. safi_t safi)
  3440. {
  3441. int ret;
  3442. struct peer *peer;
  3443. peer = peer_and_group_lookup_vty (vty, ip_str);
  3444. if (! peer)
  3445. return CMD_WARNING;
  3446. ret = peer_maximum_prefix_unset (peer, afi, safi);
  3447. return bgp_vty_return (vty, ret);
  3448. }
  3449. /* Maximum number of prefix configuration. prefix count is different
  3450. for each peer configuration. So this configuration can be set for
  3451. each peer configuration. */
  3452. DEFUN (neighbor_maximum_prefix,
  3453. neighbor_maximum_prefix_cmd,
  3454. NEIGHBOR_CMD2 "maximum-prefix <1-4294967295>",
  3455. NEIGHBOR_STR
  3456. NEIGHBOR_ADDR_STR2
  3457. "Maximum number of prefix accept from this peer\n"
  3458. "maximum no. of prefix limit\n")
  3459. {
  3460. return peer_maximum_prefix_set_vty (vty, argv[0], bgp_node_afi (vty),
  3461. bgp_node_safi (vty), argv[1], NULL, 0,
  3462. NULL);
  3463. }
  3464. DEFUN (neighbor_maximum_prefix_threshold,
  3465. neighbor_maximum_prefix_threshold_cmd,
  3466. NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> <1-100>",
  3467. NEIGHBOR_STR
  3468. NEIGHBOR_ADDR_STR2
  3469. "Maximum number of prefix accept from this peer\n"
  3470. "maximum no. of prefix limit\n"
  3471. "Threshold value (%) at which to generate a warning msg\n")
  3472. {
  3473. return peer_maximum_prefix_set_vty (vty, argv[0], bgp_node_afi (vty),
  3474. bgp_node_safi (vty), argv[1], argv[2], 0,
  3475. NULL);
  3476. }
  3477. DEFUN (neighbor_maximum_prefix_warning,
  3478. neighbor_maximum_prefix_warning_cmd,
  3479. NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> warning-only",
  3480. NEIGHBOR_STR
  3481. NEIGHBOR_ADDR_STR2
  3482. "Maximum number of prefix accept from this peer\n"
  3483. "maximum no. of prefix limit\n"
  3484. "Only give warning message when limit is exceeded\n")
  3485. {
  3486. return peer_maximum_prefix_set_vty (vty, argv[0], bgp_node_afi (vty),
  3487. bgp_node_safi (vty), argv[1], NULL, 1,
  3488. NULL);
  3489. }
  3490. DEFUN (neighbor_maximum_prefix_threshold_warning,
  3491. neighbor_maximum_prefix_threshold_warning_cmd,
  3492. NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> <1-100> warning-only",
  3493. NEIGHBOR_STR
  3494. NEIGHBOR_ADDR_STR2
  3495. "Maximum number of prefix accept from this peer\n"
  3496. "maximum no. of prefix limit\n"
  3497. "Threshold value (%) at which to generate a warning msg\n"
  3498. "Only give warning message when limit is exceeded\n")
  3499. {
  3500. return peer_maximum_prefix_set_vty (vty, argv[0], bgp_node_afi (vty),
  3501. bgp_node_safi (vty), argv[1], argv[2], 1, NULL);
  3502. }
  3503. DEFUN (neighbor_maximum_prefix_restart,
  3504. neighbor_maximum_prefix_restart_cmd,
  3505. NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> restart <1-65535>",
  3506. NEIGHBOR_STR
  3507. NEIGHBOR_ADDR_STR2
  3508. "Maximum number of prefix accept from this peer\n"
  3509. "maximum no. of prefix limit\n"
  3510. "Restart bgp connection after limit is exceeded\n"
  3511. "Restart interval in minutes")
  3512. {
  3513. return peer_maximum_prefix_set_vty (vty, argv[0], bgp_node_afi (vty),
  3514. bgp_node_safi (vty), argv[1], NULL, 0, argv[2]);
  3515. }
  3516. DEFUN (neighbor_maximum_prefix_threshold_restart,
  3517. neighbor_maximum_prefix_threshold_restart_cmd,
  3518. NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> <1-100> restart <1-65535>",
  3519. NEIGHBOR_STR
  3520. NEIGHBOR_ADDR_STR2
  3521. "Maximum number of prefix accept from this peer\n"
  3522. "maximum no. of prefix limit\n"
  3523. "Threshold value (%) at which to generate a warning msg\n"
  3524. "Restart bgp connection after limit is exceeded\n"
  3525. "Restart interval in minutes")
  3526. {
  3527. return peer_maximum_prefix_set_vty (vty, argv[0], bgp_node_afi (vty),
  3528. bgp_node_safi (vty), argv[1], argv[2], 0, argv[3]);
  3529. }
  3530. DEFUN (no_neighbor_maximum_prefix,
  3531. no_neighbor_maximum_prefix_cmd,
  3532. NO_NEIGHBOR_CMD2 "maximum-prefix",
  3533. NO_STR
  3534. NEIGHBOR_STR
  3535. NEIGHBOR_ADDR_STR2
  3536. "Maximum number of prefix accept from this peer\n")
  3537. {
  3538. return peer_maximum_prefix_unset_vty (vty, argv[0], bgp_node_afi (vty),
  3539. bgp_node_safi (vty));
  3540. }
  3541. ALIAS (no_neighbor_maximum_prefix,
  3542. no_neighbor_maximum_prefix_val_cmd,
  3543. NO_NEIGHBOR_CMD2 "maximum-prefix <1-4294967295>",
  3544. NO_STR
  3545. NEIGHBOR_STR
  3546. NEIGHBOR_ADDR_STR2
  3547. "Maximum number of prefix accept from this peer\n"
  3548. "maximum no. of prefix limit\n")
  3549. ALIAS (no_neighbor_maximum_prefix,
  3550. no_neighbor_maximum_prefix_threshold_cmd,
  3551. NO_NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> warning-only",
  3552. NO_STR
  3553. NEIGHBOR_STR
  3554. NEIGHBOR_ADDR_STR2
  3555. "Maximum number of prefix accept from this peer\n"
  3556. "maximum no. of prefix limit\n"
  3557. "Threshold value (%) at which to generate a warning msg\n")
  3558. ALIAS (no_neighbor_maximum_prefix,
  3559. no_neighbor_maximum_prefix_warning_cmd,
  3560. NO_NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> warning-only",
  3561. NO_STR
  3562. NEIGHBOR_STR
  3563. NEIGHBOR_ADDR_STR2
  3564. "Maximum number of prefix accept from this peer\n"
  3565. "maximum no. of prefix limit\n"
  3566. "Only give warning message when limit is exceeded\n")
  3567. ALIAS (no_neighbor_maximum_prefix,
  3568. no_neighbor_maximum_prefix_threshold_warning_cmd,
  3569. NO_NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> <1-100> warning-only",
  3570. NO_STR
  3571. NEIGHBOR_STR
  3572. NEIGHBOR_ADDR_STR2
  3573. "Maximum number of prefix accept from this peer\n"
  3574. "maximum no. of prefix limit\n"
  3575. "Threshold value (%) at which to generate a warning msg\n"
  3576. "Only give warning message when limit is exceeded\n")
  3577. ALIAS (no_neighbor_maximum_prefix,
  3578. no_neighbor_maximum_prefix_restart_cmd,
  3579. NO_NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> restart <1-65535>",
  3580. NO_STR
  3581. NEIGHBOR_STR
  3582. NEIGHBOR_ADDR_STR2
  3583. "Maximum number of prefix accept from this peer\n"
  3584. "maximum no. of prefix limit\n"
  3585. "Restart bgp connection after limit is exceeded\n"
  3586. "Restart interval in minutes")
  3587. ALIAS (no_neighbor_maximum_prefix,
  3588. no_neighbor_maximum_prefix_threshold_restart_cmd,
  3589. NO_NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> <1-100> restart <1-65535>",
  3590. NO_STR
  3591. NEIGHBOR_STR
  3592. NEIGHBOR_ADDR_STR2
  3593. "Maximum number of prefix accept from this peer\n"
  3594. "maximum no. of prefix limit\n"
  3595. "Threshold value (%) at which to generate a warning msg\n"
  3596. "Restart bgp connection after limit is exceeded\n"
  3597. "Restart interval in minutes")
  3598. /* "neighbor allowas-in" */
  3599. DEFUN (neighbor_allowas_in,
  3600. neighbor_allowas_in_cmd,
  3601. NEIGHBOR_CMD2 "allowas-in",
  3602. NEIGHBOR_STR
  3603. NEIGHBOR_ADDR_STR2
  3604. "Accept as-path with my AS present in it\n")
  3605. {
  3606. int ret;
  3607. struct peer *peer;
  3608. unsigned int allow_num;
  3609. peer = peer_and_group_lookup_vty (vty, argv[0]);
  3610. if (! peer)
  3611. return CMD_WARNING;
  3612. if (argc == 1)
  3613. allow_num = 3;
  3614. else
  3615. VTY_GET_INTEGER_RANGE ("AS number", allow_num, argv[1], 1, 10);
  3616. ret = peer_allowas_in_set (peer, bgp_node_afi (vty), bgp_node_safi (vty),
  3617. allow_num);
  3618. return bgp_vty_return (vty, ret);
  3619. }
  3620. ALIAS (neighbor_allowas_in,
  3621. neighbor_allowas_in_arg_cmd,
  3622. NEIGHBOR_CMD2 "allowas-in <1-10>",
  3623. NEIGHBOR_STR
  3624. NEIGHBOR_ADDR_STR2
  3625. "Accept as-path with my AS present in it\n"
  3626. "Number of occurances of AS number\n")
  3627. DEFUN (no_neighbor_allowas_in,
  3628. no_neighbor_allowas_in_cmd,
  3629. NO_NEIGHBOR_CMD2 "allowas-in",
  3630. NO_STR
  3631. NEIGHBOR_STR
  3632. NEIGHBOR_ADDR_STR2
  3633. "allow local ASN appears in aspath attribute\n")
  3634. {
  3635. int ret;
  3636. struct peer *peer;
  3637. peer = peer_and_group_lookup_vty (vty, argv[0]);
  3638. if (! peer)
  3639. return CMD_WARNING;
  3640. ret = peer_allowas_in_unset (peer, bgp_node_afi (vty), bgp_node_safi (vty));
  3641. return bgp_vty_return (vty, ret);
  3642. }
  3643. DEFUN (neighbor_ttl_security,
  3644. neighbor_ttl_security_cmd,
  3645. NEIGHBOR_CMD2 "ttl-security hops <1-254>",
  3646. NEIGHBOR_STR
  3647. NEIGHBOR_ADDR_STR2
  3648. "Specify the maximum number of hops to the BGP peer\n")
  3649. {
  3650. struct peer *peer;
  3651. int gtsm_hops;
  3652. peer = peer_and_group_lookup_vty (vty, argv[0]);
  3653. if (! peer)
  3654. return CMD_WARNING;
  3655. VTY_GET_INTEGER_RANGE ("", gtsm_hops, argv[1], 1, 254);
  3656. return bgp_vty_return (vty, peer_ttl_security_hops_set (peer, gtsm_hops));
  3657. }
  3658. DEFUN (no_neighbor_ttl_security,
  3659. no_neighbor_ttl_security_cmd,
  3660. NO_NEIGHBOR_CMD2 "ttl-security hops <1-254>",
  3661. NO_STR
  3662. NEIGHBOR_STR
  3663. NEIGHBOR_ADDR_STR2
  3664. "Specify the maximum number of hops to the BGP peer\n")
  3665. {
  3666. struct peer *peer;
  3667. peer = peer_and_group_lookup_vty (vty, argv[0]);
  3668. if (! peer)
  3669. return CMD_WARNING;
  3670. return bgp_vty_return (vty, peer_ttl_security_hops_unset (peer));
  3671. }
  3672. /* Address family configuration. */
  3673. DEFUN (address_family_ipv4,
  3674. address_family_ipv4_cmd,
  3675. "address-family ipv4",
  3676. "Enter Address Family command mode\n"
  3677. "Address family\n")
  3678. {
  3679. vty->node = BGP_IPV4_NODE;
  3680. return CMD_SUCCESS;
  3681. }
  3682. DEFUN (address_family_ipv4_safi,
  3683. address_family_ipv4_safi_cmd,
  3684. "address-family ipv4 (unicast|multicast)",
  3685. "Enter Address Family command mode\n"
  3686. "Address family\n"
  3687. "Address Family modifier\n"
  3688. "Address Family modifier\n")
  3689. {
  3690. if (strncmp (argv[0], "m", 1) == 0)
  3691. vty->node = BGP_IPV4M_NODE;
  3692. else
  3693. vty->node = BGP_IPV4_NODE;
  3694. return CMD_SUCCESS;
  3695. }
  3696. DEFUN (address_family_ipv6,
  3697. address_family_ipv6_cmd,
  3698. "address-family ipv6",
  3699. "Enter Address Family command mode\n"
  3700. "Address family\n")
  3701. {
  3702. vty->node = BGP_IPV6_NODE;
  3703. return CMD_SUCCESS;
  3704. }
  3705. DEFUN (address_family_ipv6_safi,
  3706. address_family_ipv6_safi_cmd,
  3707. "address-family ipv6 (unicast|multicast)",
  3708. "Enter Address Family command mode\n"
  3709. "Address family\n"
  3710. "Address Family modifier\n"
  3711. "Address Family modifier\n")
  3712. {
  3713. if (strncmp (argv[0], "m", 1) == 0)
  3714. vty->node = BGP_IPV6M_NODE;
  3715. else
  3716. vty->node = BGP_IPV6_NODE;
  3717. return CMD_SUCCESS;
  3718. }
  3719. DEFUN (address_family_vpnv4,
  3720. address_family_vpnv4_cmd,
  3721. "address-family vpnv4",
  3722. "Enter Address Family command mode\n"
  3723. "Address family\n")
  3724. {
  3725. vty->node = BGP_VPNV4_NODE;
  3726. return CMD_SUCCESS;
  3727. }
  3728. ALIAS (address_family_vpnv4,
  3729. address_family_vpnv4_unicast_cmd,
  3730. "address-family vpnv4 unicast",
  3731. "Enter Address Family command mode\n"
  3732. "Address family\n"
  3733. "Address Family Modifier\n")
  3734. DEFUN (address_family_vpnv6,
  3735. address_family_vpnv6_cmd,
  3736. "address-family vpnv6",
  3737. "Enter Address Family command mode\n"
  3738. "Address family\n")
  3739. {
  3740. vty->node = BGP_VPNV6_NODE;
  3741. return CMD_SUCCESS;
  3742. }
  3743. ALIAS (address_family_vpnv6,
  3744. address_family_vpnv6_unicast_cmd,
  3745. "address-family vpnv6 unicast",
  3746. "Enter Address Family command mode\n"
  3747. "Address family\n"
  3748. "Address Family Modifier\n")
  3749. DEFUN (address_family_encap,
  3750. address_family_encap_cmd,
  3751. "address-family encap",
  3752. "Enter Address Family command mode\n"
  3753. "Address family\n")
  3754. {
  3755. vty->node = BGP_ENCAP_NODE;
  3756. return CMD_SUCCESS;
  3757. }
  3758. ALIAS (address_family_encap,
  3759. address_family_encapv4_cmd,
  3760. "address-family encapv4",
  3761. "Enter Address Family command mode\n"
  3762. "Address family\n")
  3763. DEFUN (address_family_encapv6,
  3764. address_family_encapv6_cmd,
  3765. "address-family encapv6",
  3766. "Enter Address Family command mode\n"
  3767. "Address family\n")
  3768. {
  3769. vty->node = BGP_ENCAPV6_NODE;
  3770. return CMD_SUCCESS;
  3771. }
  3772. DEFUN (exit_address_family,
  3773. exit_address_family_cmd,
  3774. "exit-address-family",
  3775. "Exit from Address Family configuration mode\n")
  3776. {
  3777. /* should match list in command.c:config_exit */
  3778. if (vty->node == BGP_IPV4_NODE
  3779. || vty->node == BGP_ENCAP_NODE
  3780. || vty->node == BGP_ENCAPV6_NODE
  3781. || vty->node == BGP_IPV4M_NODE
  3782. || vty->node == BGP_VPNV4_NODE
  3783. || vty->node == BGP_VPNV6_NODE
  3784. || vty->node == BGP_IPV6_NODE
  3785. || vty->node == BGP_IPV6M_NODE)
  3786. vty->node = BGP_NODE;
  3787. return CMD_SUCCESS;
  3788. }
  3789. /* BGP clear sort. */
  3790. enum clear_sort
  3791. {
  3792. clear_all,
  3793. clear_peer,
  3794. clear_group,
  3795. clear_external,
  3796. clear_as
  3797. };
  3798. static void
  3799. bgp_clear_vty_error (struct vty *vty, struct peer *peer, afi_t afi,
  3800. safi_t safi, int error)
  3801. {
  3802. switch (error)
  3803. {
  3804. case BGP_ERR_AF_UNCONFIGURED:
  3805. vty_out (vty,
  3806. "%%BGP: Enable %s %s address family for the neighbor %s%s",
  3807. afi == AFI_IP6 ? "IPv6" : safi == SAFI_MPLS_VPN ? "VPNv4" : "IPv4",
  3808. safi == SAFI_MULTICAST ? "Multicast" : "Unicast",
  3809. peer->host, VTY_NEWLINE);
  3810. break;
  3811. case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED:
  3812. vty_out (vty, "%%BGP: Inbound soft reconfig for %s not possible as it%s has neither refresh capability, nor inbound soft reconfig%s", peer->host, VTY_NEWLINE, VTY_NEWLINE);
  3813. break;
  3814. default:
  3815. break;
  3816. }
  3817. }
  3818. /* `clear ip bgp' functions. */
  3819. static int
  3820. bgp_clear (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi,
  3821. enum clear_sort sort,enum bgp_clear_type stype, const char *arg)
  3822. {
  3823. int ret;
  3824. struct peer *peer;
  3825. struct listnode *node, *nnode;
  3826. /* Clear all neighbors. */
  3827. if (sort == clear_all)
  3828. {
  3829. for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
  3830. {
  3831. if (stype == BGP_CLEAR_SOFT_NONE)
  3832. ret = peer_clear (peer);
  3833. else
  3834. ret = peer_clear_soft (peer, afi, safi, stype);
  3835. if (ret < 0)
  3836. bgp_clear_vty_error (vty, peer, afi, safi, ret);
  3837. }
  3838. return CMD_SUCCESS;
  3839. }
  3840. /* Clear specified neighbors. */
  3841. if (sort == clear_peer)
  3842. {
  3843. union sockunion su;
  3844. int ret;
  3845. /* Make sockunion for lookup. */
  3846. ret = str2sockunion (arg, &su);
  3847. if (ret < 0)
  3848. {
  3849. vty_out (vty, "Malformed address: %s%s", arg, VTY_NEWLINE);
  3850. return CMD_WARNING;
  3851. }
  3852. peer = peer_lookup (bgp, &su);
  3853. if (! peer)
  3854. {
  3855. vty_out (vty, "%%BGP: Unknown neighbor - \"%s\"%s", arg, VTY_NEWLINE);
  3856. return CMD_WARNING;
  3857. }
  3858. if (stype == BGP_CLEAR_SOFT_NONE)
  3859. ret = peer_clear (peer);
  3860. else
  3861. ret = peer_clear_soft (peer, afi, safi, stype);
  3862. if (ret < 0)
  3863. bgp_clear_vty_error (vty, peer, afi, safi, ret);
  3864. return CMD_SUCCESS;
  3865. }
  3866. /* Clear all peer-group members. */
  3867. if (sort == clear_group)
  3868. {
  3869. struct peer_group *group;
  3870. group = peer_group_lookup (bgp, arg);
  3871. if (! group)
  3872. {
  3873. vty_out (vty, "%%BGP: No such peer-group %s%s", arg, VTY_NEWLINE);
  3874. return CMD_WARNING;
  3875. }
  3876. for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
  3877. {
  3878. if (stype == BGP_CLEAR_SOFT_NONE)
  3879. {
  3880. ret = peer_clear (peer);
  3881. continue;
  3882. }
  3883. if (! peer->af_group[afi][safi])
  3884. continue;
  3885. ret = peer_clear_soft (peer, afi, safi, stype);
  3886. if (ret < 0)
  3887. bgp_clear_vty_error (vty, peer, afi, safi, ret);
  3888. }
  3889. return CMD_SUCCESS;
  3890. }
  3891. if (sort == clear_external)
  3892. {
  3893. for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
  3894. {
  3895. if (peer->sort == BGP_PEER_IBGP)
  3896. continue;
  3897. if (stype == BGP_CLEAR_SOFT_NONE)
  3898. ret = peer_clear (peer);
  3899. else
  3900. ret = peer_clear_soft (peer, afi, safi, stype);
  3901. if (ret < 0)
  3902. bgp_clear_vty_error (vty, peer, afi, safi, ret);
  3903. }
  3904. return CMD_SUCCESS;
  3905. }
  3906. if (sort == clear_as)
  3907. {
  3908. as_t as;
  3909. int find = 0;
  3910. VTY_GET_INTEGER_RANGE ("AS", as, arg, 1, BGP_AS4_MAX);
  3911. for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
  3912. {
  3913. if (peer->as != as)
  3914. continue;
  3915. find = 1;
  3916. if (stype == BGP_CLEAR_SOFT_NONE)
  3917. ret = peer_clear (peer);
  3918. else
  3919. ret = peer_clear_soft (peer, afi, safi, stype);
  3920. if (ret < 0)
  3921. bgp_clear_vty_error (vty, peer, afi, safi, ret);
  3922. }
  3923. if (! find)
  3924. vty_out (vty, "%%BGP: No peer is configured with AS %s%s", arg,
  3925. VTY_NEWLINE);
  3926. return CMD_SUCCESS;
  3927. }
  3928. return CMD_SUCCESS;
  3929. }
  3930. static int
  3931. bgp_clear_vty (struct vty *vty, const char *name, afi_t afi, safi_t safi,
  3932. enum clear_sort sort, enum bgp_clear_type stype,
  3933. const char *arg)
  3934. {
  3935. struct bgp *bgp;
  3936. /* BGP structure lookup. */
  3937. if (name)
  3938. {
  3939. bgp = bgp_lookup_by_name (name);
  3940. if (bgp == NULL)
  3941. {
  3942. vty_out (vty, "Can't find BGP view %s%s", name, VTY_NEWLINE);
  3943. return CMD_WARNING;
  3944. }
  3945. }
  3946. else
  3947. {
  3948. bgp = bgp_get_default ();
  3949. if (bgp == NULL)
  3950. {
  3951. vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
  3952. return CMD_WARNING;
  3953. }
  3954. }
  3955. return bgp_clear (vty, bgp, afi, safi, sort, stype, arg);
  3956. }
  3957. DEFUN (clear_ip_bgp_all,
  3958. clear_ip_bgp_all_cmd,
  3959. "clear ip bgp *",
  3960. CLEAR_STR
  3961. IP_STR
  3962. BGP_STR
  3963. "Clear all peers\n")
  3964. {
  3965. if (argc == 1)
  3966. return bgp_clear_vty (vty, argv[0], 0, 0, clear_all, BGP_CLEAR_SOFT_NONE, NULL);
  3967. return bgp_clear_vty (vty, NULL, 0, 0, clear_all, BGP_CLEAR_SOFT_NONE, NULL);
  3968. }
  3969. ALIAS (clear_ip_bgp_all,
  3970. clear_bgp_all_cmd,
  3971. "clear bgp *",
  3972. CLEAR_STR
  3973. BGP_STR
  3974. "Clear all peers\n")
  3975. ALIAS (clear_ip_bgp_all,
  3976. clear_bgp_ipv6_all_cmd,
  3977. "clear bgp ipv6 *",
  3978. CLEAR_STR
  3979. BGP_STR
  3980. "Address family\n"
  3981. "Clear all peers\n")
  3982. ALIAS (clear_ip_bgp_all,
  3983. clear_ip_bgp_instance_all_cmd,
  3984. "clear ip bgp view WORD *",
  3985. CLEAR_STR
  3986. IP_STR
  3987. BGP_STR
  3988. "BGP view\n"
  3989. "view name\n"
  3990. "Clear all peers\n")
  3991. ALIAS (clear_ip_bgp_all,
  3992. clear_bgp_instance_all_cmd,
  3993. "clear bgp view WORD *",
  3994. CLEAR_STR
  3995. BGP_STR
  3996. "BGP view\n"
  3997. "view name\n"
  3998. "Clear all peers\n")
  3999. DEFUN (clear_ip_bgp_peer,
  4000. clear_ip_bgp_peer_cmd,
  4001. "clear ip bgp (A.B.C.D|X:X::X:X)",
  4002. CLEAR_STR
  4003. IP_STR
  4004. BGP_STR
  4005. "BGP neighbor IP address to clear\n"
  4006. "BGP IPv6 neighbor to clear\n")
  4007. {
  4008. return bgp_clear_vty (vty, NULL, 0, 0, clear_peer, BGP_CLEAR_SOFT_NONE, argv[0]);
  4009. }
  4010. ALIAS (clear_ip_bgp_peer,
  4011. clear_bgp_peer_cmd,
  4012. "clear bgp (A.B.C.D|X:X::X:X)",
  4013. CLEAR_STR
  4014. BGP_STR
  4015. "BGP neighbor address to clear\n"
  4016. "BGP IPv6 neighbor to clear\n")
  4017. ALIAS (clear_ip_bgp_peer,
  4018. clear_bgp_ipv6_peer_cmd,
  4019. "clear bgp ipv6 (A.B.C.D|X:X::X:X)",
  4020. CLEAR_STR
  4021. BGP_STR
  4022. "Address family\n"
  4023. "BGP neighbor address to clear\n"
  4024. "BGP IPv6 neighbor to clear\n")
  4025. DEFUN (clear_ip_bgp_peer_group,
  4026. clear_ip_bgp_peer_group_cmd,
  4027. "clear ip bgp peer-group WORD",
  4028. CLEAR_STR
  4029. IP_STR
  4030. BGP_STR
  4031. "Clear all members of peer-group\n"
  4032. "BGP peer-group name\n")
  4033. {
  4034. return bgp_clear_vty (vty, NULL, 0, 0, clear_group, BGP_CLEAR_SOFT_NONE, argv[0]);
  4035. }
  4036. ALIAS (clear_ip_bgp_peer_group,
  4037. clear_bgp_peer_group_cmd,
  4038. "clear bgp peer-group WORD",
  4039. CLEAR_STR
  4040. BGP_STR
  4041. "Clear all members of peer-group\n"
  4042. "BGP peer-group name\n")
  4043. ALIAS (clear_ip_bgp_peer_group,
  4044. clear_bgp_ipv6_peer_group_cmd,
  4045. "clear bgp ipv6 peer-group WORD",
  4046. CLEAR_STR
  4047. BGP_STR
  4048. "Address family\n"
  4049. "Clear all members of peer-group\n"
  4050. "BGP peer-group name\n")
  4051. DEFUN (clear_ip_bgp_external,
  4052. clear_ip_bgp_external_cmd,
  4053. "clear ip bgp external",
  4054. CLEAR_STR
  4055. IP_STR
  4056. BGP_STR
  4057. "Clear all external peers\n")
  4058. {
  4059. return bgp_clear_vty (vty, NULL, 0, 0, clear_external, BGP_CLEAR_SOFT_NONE, NULL);
  4060. }
  4061. ALIAS (clear_ip_bgp_external,
  4062. clear_bgp_external_cmd,
  4063. "clear bgp external",
  4064. CLEAR_STR
  4065. BGP_STR
  4066. "Clear all external peers\n")
  4067. ALIAS (clear_ip_bgp_external,
  4068. clear_bgp_ipv6_external_cmd,
  4069. "clear bgp ipv6 external",
  4070. CLEAR_STR
  4071. BGP_STR
  4072. "Address family\n"
  4073. "Clear all external peers\n")
  4074. DEFUN (clear_ip_bgp_as,
  4075. clear_ip_bgp_as_cmd,
  4076. "clear ip bgp " CMD_AS_RANGE,
  4077. CLEAR_STR
  4078. IP_STR
  4079. BGP_STR
  4080. "Clear peers with the AS number\n")
  4081. {
  4082. return bgp_clear_vty (vty, NULL, 0, 0, clear_as, BGP_CLEAR_SOFT_NONE, argv[0]);
  4083. }
  4084. ALIAS (clear_ip_bgp_as,
  4085. clear_bgp_as_cmd,
  4086. "clear bgp " CMD_AS_RANGE,
  4087. CLEAR_STR
  4088. BGP_STR
  4089. "Clear peers with the AS number\n")
  4090. ALIAS (clear_ip_bgp_as,
  4091. clear_bgp_ipv6_as_cmd,
  4092. "clear bgp ipv6 " CMD_AS_RANGE,
  4093. CLEAR_STR
  4094. BGP_STR
  4095. "Address family\n"
  4096. "Clear peers with the AS number\n")
  4097. /* Outbound soft-reconfiguration */
  4098. DEFUN (clear_ip_bgp_all_soft_out,
  4099. clear_ip_bgp_all_soft_out_cmd,
  4100. "clear ip bgp * soft out",
  4101. CLEAR_STR
  4102. IP_STR
  4103. BGP_STR
  4104. "Clear all peers\n"
  4105. "Soft reconfig\n"
  4106. "Soft reconfig outbound update\n")
  4107. {
  4108. if (argc == 1)
  4109. return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, clear_all,
  4110. BGP_CLEAR_SOFT_OUT, NULL);
  4111. return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
  4112. BGP_CLEAR_SOFT_OUT, NULL);
  4113. }
  4114. ALIAS (clear_ip_bgp_all_soft_out,
  4115. clear_ip_bgp_all_out_cmd,
  4116. "clear ip bgp * out",
  4117. CLEAR_STR
  4118. IP_STR
  4119. BGP_STR
  4120. "Clear all peers\n"
  4121. "Soft reconfig outbound update\n")
  4122. ALIAS (clear_ip_bgp_all_soft_out,
  4123. clear_ip_bgp_instance_all_soft_out_cmd,
  4124. "clear ip bgp view WORD * soft out",
  4125. CLEAR_STR
  4126. IP_STR
  4127. BGP_STR
  4128. "BGP view\n"
  4129. "view name\n"
  4130. "Clear all peers\n"
  4131. "Soft reconfig\n"
  4132. "Soft reconfig outbound update\n")
  4133. DEFUN (clear_ip_bgp_all_ipv4_soft_out,
  4134. clear_ip_bgp_all_ipv4_soft_out_cmd,
  4135. "clear ip bgp * ipv4 (unicast|multicast) soft out",
  4136. CLEAR_STR
  4137. IP_STR
  4138. BGP_STR
  4139. "Clear all peers\n"
  4140. "Address family\n"
  4141. "Address Family modifier\n"
  4142. "Address Family modifier\n"
  4143. "Soft reconfig\n"
  4144. "Soft reconfig outbound update\n")
  4145. {
  4146. if (strncmp (argv[0], "m", 1) == 0)
  4147. return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_all,
  4148. BGP_CLEAR_SOFT_OUT, NULL);
  4149. return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
  4150. BGP_CLEAR_SOFT_OUT, NULL);
  4151. }
  4152. ALIAS (clear_ip_bgp_all_ipv4_soft_out,
  4153. clear_ip_bgp_all_ipv4_out_cmd,
  4154. "clear ip bgp * ipv4 (unicast|multicast) out",
  4155. CLEAR_STR
  4156. IP_STR
  4157. BGP_STR
  4158. "Clear all peers\n"
  4159. "Address family\n"
  4160. "Address Family modifier\n"
  4161. "Address Family modifier\n"
  4162. "Soft reconfig outbound update\n")
  4163. DEFUN (clear_ip_bgp_instance_all_ipv4_soft_out,
  4164. clear_ip_bgp_instance_all_ipv4_soft_out_cmd,
  4165. "clear ip bgp view WORD * ipv4 (unicast|multicast) soft out",
  4166. CLEAR_STR
  4167. IP_STR
  4168. BGP_STR
  4169. "BGP view\n"
  4170. "view name\n"
  4171. "Clear all peers\n"
  4172. "Address family\n"
  4173. "Address Family modifier\n"
  4174. "Address Family modifier\n"
  4175. "Soft reconfig outbound update\n")
  4176. {
  4177. if (strncmp (argv[1], "m", 1) == 0)
  4178. return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_MULTICAST, clear_all,
  4179. BGP_CLEAR_SOFT_OUT, NULL);
  4180. return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, clear_all,
  4181. BGP_CLEAR_SOFT_OUT, NULL);
  4182. }
  4183. DEFUN (clear_ip_bgp_all_vpnv4_soft_out,
  4184. clear_ip_bgp_all_vpnv4_soft_out_cmd,
  4185. "clear ip bgp * vpnv4 unicast soft out",
  4186. CLEAR_STR
  4187. IP_STR
  4188. BGP_STR
  4189. "Clear all peers\n"
  4190. "Address family\n"
  4191. "Address Family Modifier\n"
  4192. "Soft reconfig\n"
  4193. "Soft reconfig outbound update\n")
  4194. {
  4195. return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_all,
  4196. BGP_CLEAR_SOFT_OUT, NULL);
  4197. }
  4198. ALIAS (clear_ip_bgp_all_vpnv4_soft_out,
  4199. clear_ip_bgp_all_vpnv4_out_cmd,
  4200. "clear ip bgp * vpnv4 unicast out",
  4201. CLEAR_STR
  4202. IP_STR
  4203. BGP_STR
  4204. "Clear all peers\n"
  4205. "Address family\n"
  4206. "Address Family Modifier\n"
  4207. "Soft reconfig outbound update\n")
  4208. DEFUN (clear_ip_bgp_all_encap_soft_out,
  4209. clear_ip_bgp_all_encap_soft_out_cmd,
  4210. "clear ip bgp * encap unicast soft out",
  4211. CLEAR_STR
  4212. IP_STR
  4213. BGP_STR
  4214. "Clear all peers\n"
  4215. "Address family\n"
  4216. "Address Family Modifier\n"
  4217. "Soft reconfig\n"
  4218. "Soft reconfig outbound update\n")
  4219. {
  4220. return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_ENCAP, clear_all,
  4221. BGP_CLEAR_SOFT_OUT, NULL);
  4222. }
  4223. ALIAS (clear_ip_bgp_all_encap_soft_out,
  4224. clear_ip_bgp_all_encap_out_cmd,
  4225. "clear ip bgp * encap unicast out",
  4226. CLEAR_STR
  4227. IP_STR
  4228. BGP_STR
  4229. "Clear all peers\n"
  4230. "Address family\n"
  4231. "Address Family Modifier\n"
  4232. "Soft reconfig outbound update\n")
  4233. DEFUN (clear_bgp_all_soft_out,
  4234. clear_bgp_all_soft_out_cmd,
  4235. "clear bgp * soft out",
  4236. CLEAR_STR
  4237. BGP_STR
  4238. "Clear all peers\n"
  4239. "Soft reconfig\n"
  4240. "Soft reconfig outbound update\n")
  4241. {
  4242. if (argc == 1)
  4243. return bgp_clear_vty (vty, argv[0], AFI_IP6, SAFI_UNICAST, clear_all,
  4244. BGP_CLEAR_SOFT_OUT, NULL);
  4245. return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_all,
  4246. BGP_CLEAR_SOFT_OUT, NULL);
  4247. }
  4248. ALIAS (clear_bgp_all_soft_out,
  4249. clear_bgp_instance_all_soft_out_cmd,
  4250. "clear bgp view WORD * soft out",
  4251. CLEAR_STR
  4252. BGP_STR
  4253. "BGP view\n"
  4254. "view name\n"
  4255. "Clear all peers\n"
  4256. "Soft reconfig\n"
  4257. "Soft reconfig outbound update\n")
  4258. ALIAS (clear_bgp_all_soft_out,
  4259. clear_bgp_all_out_cmd,
  4260. "clear bgp * out",
  4261. CLEAR_STR
  4262. BGP_STR
  4263. "Clear all peers\n"
  4264. "Soft reconfig outbound update\n")
  4265. ALIAS (clear_bgp_all_soft_out,
  4266. clear_bgp_ipv6_all_soft_out_cmd,
  4267. "clear bgp ipv6 * soft out",
  4268. CLEAR_STR
  4269. BGP_STR
  4270. "Address family\n"
  4271. "Clear all peers\n"
  4272. "Soft reconfig\n"
  4273. "Soft reconfig outbound update\n")
  4274. ALIAS (clear_bgp_all_soft_out,
  4275. clear_bgp_ipv6_all_out_cmd,
  4276. "clear bgp ipv6 * out",
  4277. CLEAR_STR
  4278. BGP_STR
  4279. "Address family\n"
  4280. "Clear all peers\n"
  4281. "Soft reconfig outbound update\n")
  4282. DEFUN (clear_ip_bgp_peer_soft_out,
  4283. clear_ip_bgp_peer_soft_out_cmd,
  4284. "clear ip bgp A.B.C.D soft out",
  4285. CLEAR_STR
  4286. IP_STR
  4287. BGP_STR
  4288. "BGP neighbor address to clear\n"
  4289. "Soft reconfig\n"
  4290. "Soft reconfig outbound update\n")
  4291. {
  4292. return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
  4293. BGP_CLEAR_SOFT_OUT, argv[0]);
  4294. }
  4295. ALIAS (clear_ip_bgp_peer_soft_out,
  4296. clear_ip_bgp_peer_out_cmd,
  4297. "clear ip bgp A.B.C.D out",
  4298. CLEAR_STR
  4299. IP_STR
  4300. BGP_STR
  4301. "BGP neighbor address to clear\n"
  4302. "Soft reconfig outbound update\n")
  4303. DEFUN (clear_ip_bgp_peer_ipv4_soft_out,
  4304. clear_ip_bgp_peer_ipv4_soft_out_cmd,
  4305. "clear ip bgp A.B.C.D ipv4 (unicast|multicast) soft out",
  4306. CLEAR_STR
  4307. IP_STR
  4308. BGP_STR
  4309. "BGP neighbor address to clear\n"
  4310. "Address family\n"
  4311. "Address Family modifier\n"
  4312. "Address Family modifier\n"
  4313. "Soft reconfig\n"
  4314. "Soft reconfig outbound update\n")
  4315. {
  4316. if (strncmp (argv[1], "m", 1) == 0)
  4317. return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_peer,
  4318. BGP_CLEAR_SOFT_OUT, argv[0]);
  4319. return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
  4320. BGP_CLEAR_SOFT_OUT, argv[0]);
  4321. }
  4322. ALIAS (clear_ip_bgp_peer_ipv4_soft_out,
  4323. clear_ip_bgp_peer_ipv4_out_cmd,
  4324. "clear ip bgp A.B.C.D ipv4 (unicast|multicast) out",
  4325. CLEAR_STR
  4326. IP_STR
  4327. BGP_STR
  4328. "BGP neighbor address to clear\n"
  4329. "Address family\n"
  4330. "Address Family modifier\n"
  4331. "Address Family modifier\n"
  4332. "Soft reconfig outbound update\n")
  4333. DEFUN (clear_ip_bgp_peer_vpnv4_soft_out,
  4334. clear_ip_bgp_peer_vpnv4_soft_out_cmd,
  4335. "clear ip bgp A.B.C.D vpnv4 unicast soft out",
  4336. CLEAR_STR
  4337. IP_STR
  4338. BGP_STR
  4339. "BGP neighbor address to clear\n"
  4340. "Address family\n"
  4341. "Address Family Modifier\n"
  4342. "Soft reconfig\n"
  4343. "Soft reconfig outbound update\n")
  4344. {
  4345. return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_peer,
  4346. BGP_CLEAR_SOFT_OUT, argv[0]);
  4347. }
  4348. ALIAS (clear_ip_bgp_peer_vpnv4_soft_out,
  4349. clear_ip_bgp_peer_vpnv4_out_cmd,
  4350. "clear ip bgp A.B.C.D vpnv4 unicast out",
  4351. CLEAR_STR
  4352. IP_STR
  4353. BGP_STR
  4354. "BGP neighbor address to clear\n"
  4355. "Address family\n"
  4356. "Address Family Modifier\n"
  4357. "Soft reconfig outbound update\n")
  4358. DEFUN (clear_ip_bgp_peer_encap_soft_out,
  4359. clear_ip_bgp_peer_encap_soft_out_cmd,
  4360. "clear ip bgp A.B.C.D encap unicast soft out",
  4361. CLEAR_STR
  4362. IP_STR
  4363. BGP_STR
  4364. "BGP neighbor address to clear\n"
  4365. "Address family\n"
  4366. "Address Family Modifier\n"
  4367. "Soft reconfig\n"
  4368. "Soft reconfig outbound update\n")
  4369. {
  4370. return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_ENCAP, clear_peer,
  4371. BGP_CLEAR_SOFT_OUT, argv[0]);
  4372. }
  4373. ALIAS (clear_ip_bgp_peer_encap_soft_out,
  4374. clear_ip_bgp_peer_encap_out_cmd,
  4375. "clear ip bgp A.B.C.D encap unicast out",
  4376. CLEAR_STR
  4377. IP_STR
  4378. BGP_STR
  4379. "BGP neighbor address to clear\n"
  4380. "Address family\n"
  4381. "Address Family Modifier\n"
  4382. "Soft reconfig outbound update\n")
  4383. DEFUN (clear_bgp_peer_soft_out,
  4384. clear_bgp_peer_soft_out_cmd,
  4385. "clear bgp (A.B.C.D|X:X::X:X) soft out",
  4386. CLEAR_STR
  4387. BGP_STR
  4388. "BGP neighbor address to clear\n"
  4389. "BGP IPv6 neighbor to clear\n"
  4390. "Soft reconfig\n"
  4391. "Soft reconfig outbound update\n")
  4392. {
  4393. return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_peer,
  4394. BGP_CLEAR_SOFT_OUT, argv[0]);
  4395. }
  4396. ALIAS (clear_bgp_peer_soft_out,
  4397. clear_bgp_ipv6_peer_soft_out_cmd,
  4398. "clear bgp ipv6 (A.B.C.D|X:X::X:X) soft out",
  4399. CLEAR_STR
  4400. BGP_STR
  4401. "Address family\n"
  4402. "BGP neighbor address to clear\n"
  4403. "BGP IPv6 neighbor to clear\n"
  4404. "Soft reconfig\n"
  4405. "Soft reconfig outbound update\n")
  4406. ALIAS (clear_bgp_peer_soft_out,
  4407. clear_bgp_peer_out_cmd,
  4408. "clear bgp (A.B.C.D|X:X::X:X) out",
  4409. CLEAR_STR
  4410. BGP_STR
  4411. "BGP neighbor address to clear\n"
  4412. "BGP IPv6 neighbor to clear\n"
  4413. "Soft reconfig outbound update\n")
  4414. ALIAS (clear_bgp_peer_soft_out,
  4415. clear_bgp_ipv6_peer_out_cmd,
  4416. "clear bgp ipv6 (A.B.C.D|X:X::X:X) out",
  4417. CLEAR_STR
  4418. BGP_STR
  4419. "Address family\n"
  4420. "BGP neighbor address to clear\n"
  4421. "BGP IPv6 neighbor to clear\n"
  4422. "Soft reconfig outbound update\n")
  4423. DEFUN (clear_ip_bgp_peer_group_soft_out,
  4424. clear_ip_bgp_peer_group_soft_out_cmd,
  4425. "clear ip bgp peer-group WORD soft out",
  4426. CLEAR_STR
  4427. IP_STR
  4428. BGP_STR
  4429. "Clear all members of peer-group\n"
  4430. "BGP peer-group name\n"
  4431. "Soft reconfig\n"
  4432. "Soft reconfig outbound update\n")
  4433. {
  4434. return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
  4435. BGP_CLEAR_SOFT_OUT, argv[0]);
  4436. }
  4437. ALIAS (clear_ip_bgp_peer_group_soft_out,
  4438. clear_ip_bgp_peer_group_out_cmd,
  4439. "clear ip bgp peer-group WORD out",
  4440. CLEAR_STR
  4441. IP_STR
  4442. BGP_STR
  4443. "Clear all members of peer-group\n"
  4444. "BGP peer-group name\n"
  4445. "Soft reconfig outbound update\n")
  4446. DEFUN (clear_ip_bgp_peer_group_ipv4_soft_out,
  4447. clear_ip_bgp_peer_group_ipv4_soft_out_cmd,
  4448. "clear ip bgp peer-group WORD ipv4 (unicast|multicast) soft out",
  4449. CLEAR_STR
  4450. IP_STR
  4451. BGP_STR
  4452. "Clear all members of peer-group\n"
  4453. "BGP peer-group name\n"
  4454. "Address family\n"
  4455. "Address Family modifier\n"
  4456. "Address Family modifier\n"
  4457. "Soft reconfig\n"
  4458. "Soft reconfig outbound update\n")
  4459. {
  4460. if (strncmp (argv[1], "m", 1) == 0)
  4461. return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_group,
  4462. BGP_CLEAR_SOFT_OUT, argv[0]);
  4463. return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
  4464. BGP_CLEAR_SOFT_OUT, argv[0]);
  4465. }
  4466. ALIAS (clear_ip_bgp_peer_group_ipv4_soft_out,
  4467. clear_ip_bgp_peer_group_ipv4_out_cmd,
  4468. "clear ip bgp peer-group WORD ipv4 (unicast|multicast) out",
  4469. CLEAR_STR
  4470. IP_STR
  4471. BGP_STR
  4472. "Clear all members of peer-group\n"
  4473. "BGP peer-group name\n"
  4474. "Address family\n"
  4475. "Address Family modifier\n"
  4476. "Address Family modifier\n"
  4477. "Soft reconfig outbound update\n")
  4478. DEFUN (clear_bgp_peer_group_soft_out,
  4479. clear_bgp_peer_group_soft_out_cmd,
  4480. "clear bgp peer-group WORD soft out",
  4481. CLEAR_STR
  4482. BGP_STR
  4483. "Clear all members of peer-group\n"
  4484. "BGP peer-group name\n"
  4485. "Soft reconfig\n"
  4486. "Soft reconfig outbound update\n")
  4487. {
  4488. return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_group,
  4489. BGP_CLEAR_SOFT_OUT, argv[0]);
  4490. }
  4491. ALIAS (clear_bgp_peer_group_soft_out,
  4492. clear_bgp_ipv6_peer_group_soft_out_cmd,
  4493. "clear bgp ipv6 peer-group WORD soft out",
  4494. CLEAR_STR
  4495. BGP_STR
  4496. "Address family\n"
  4497. "Clear all members of peer-group\n"
  4498. "BGP peer-group name\n"
  4499. "Soft reconfig\n"
  4500. "Soft reconfig outbound update\n")
  4501. ALIAS (clear_bgp_peer_group_soft_out,
  4502. clear_bgp_peer_group_out_cmd,
  4503. "clear bgp peer-group WORD out",
  4504. CLEAR_STR
  4505. BGP_STR
  4506. "Clear all members of peer-group\n"
  4507. "BGP peer-group name\n"
  4508. "Soft reconfig outbound update\n")
  4509. ALIAS (clear_bgp_peer_group_soft_out,
  4510. clear_bgp_ipv6_peer_group_out_cmd,
  4511. "clear bgp ipv6 peer-group WORD out",
  4512. CLEAR_STR
  4513. BGP_STR
  4514. "Address family\n"
  4515. "Clear all members of peer-group\n"
  4516. "BGP peer-group name\n"
  4517. "Soft reconfig outbound update\n")
  4518. DEFUN (clear_ip_bgp_external_soft_out,
  4519. clear_ip_bgp_external_soft_out_cmd,
  4520. "clear ip bgp external soft out",
  4521. CLEAR_STR
  4522. IP_STR
  4523. BGP_STR
  4524. "Clear all external peers\n"
  4525. "Soft reconfig\n"
  4526. "Soft reconfig outbound update\n")
  4527. {
  4528. return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
  4529. BGP_CLEAR_SOFT_OUT, NULL);
  4530. }
  4531. ALIAS (clear_ip_bgp_external_soft_out,
  4532. clear_ip_bgp_external_out_cmd,
  4533. "clear ip bgp external out",
  4534. CLEAR_STR
  4535. IP_STR
  4536. BGP_STR
  4537. "Clear all external peers\n"
  4538. "Soft reconfig outbound update\n")
  4539. DEFUN (clear_ip_bgp_external_ipv4_soft_out,
  4540. clear_ip_bgp_external_ipv4_soft_out_cmd,
  4541. "clear ip bgp external ipv4 (unicast|multicast) soft out",
  4542. CLEAR_STR
  4543. IP_STR
  4544. BGP_STR
  4545. "Clear all external peers\n"
  4546. "Address family\n"
  4547. "Address Family modifier\n"
  4548. "Address Family modifier\n"
  4549. "Soft reconfig\n"
  4550. "Soft reconfig outbound update\n")
  4551. {
  4552. if (strncmp (argv[0], "m", 1) == 0)
  4553. return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_external,
  4554. BGP_CLEAR_SOFT_OUT, NULL);
  4555. return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
  4556. BGP_CLEAR_SOFT_OUT, NULL);
  4557. }
  4558. ALIAS (clear_ip_bgp_external_ipv4_soft_out,
  4559. clear_ip_bgp_external_ipv4_out_cmd,
  4560. "clear ip bgp external ipv4 (unicast|multicast) out",
  4561. CLEAR_STR
  4562. IP_STR
  4563. BGP_STR
  4564. "Clear all external peers\n"
  4565. "Address family\n"
  4566. "Address Family modifier\n"
  4567. "Address Family modifier\n"
  4568. "Soft reconfig outbound update\n")
  4569. DEFUN (clear_bgp_external_soft_out,
  4570. clear_bgp_external_soft_out_cmd,
  4571. "clear bgp external soft out",
  4572. CLEAR_STR
  4573. BGP_STR
  4574. "Clear all external peers\n"
  4575. "Soft reconfig\n"
  4576. "Soft reconfig outbound update\n")
  4577. {
  4578. return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_external,
  4579. BGP_CLEAR_SOFT_OUT, NULL);
  4580. }
  4581. ALIAS (clear_bgp_external_soft_out,
  4582. clear_bgp_ipv6_external_soft_out_cmd,
  4583. "clear bgp ipv6 external soft out",
  4584. CLEAR_STR
  4585. BGP_STR
  4586. "Address family\n"
  4587. "Clear all external peers\n"
  4588. "Soft reconfig\n"
  4589. "Soft reconfig outbound update\n")
  4590. ALIAS (clear_bgp_external_soft_out,
  4591. clear_bgp_external_out_cmd,
  4592. "clear bgp external out",
  4593. CLEAR_STR
  4594. BGP_STR
  4595. "Clear all external peers\n"
  4596. "Soft reconfig outbound update\n")
  4597. ALIAS (clear_bgp_external_soft_out,
  4598. clear_bgp_ipv6_external_out_cmd,
  4599. "clear bgp ipv6 external WORD out",
  4600. CLEAR_STR
  4601. BGP_STR
  4602. "Address family\n"
  4603. "Clear all external peers\n"
  4604. "Soft reconfig outbound update\n")
  4605. DEFUN (clear_ip_bgp_as_soft_out,
  4606. clear_ip_bgp_as_soft_out_cmd,
  4607. "clear ip bgp " CMD_AS_RANGE " soft out",
  4608. CLEAR_STR
  4609. IP_STR
  4610. BGP_STR
  4611. "Clear peers with the AS number\n"
  4612. "Soft reconfig\n"
  4613. "Soft reconfig outbound update\n")
  4614. {
  4615. return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as,
  4616. BGP_CLEAR_SOFT_OUT, argv[0]);
  4617. }
  4618. ALIAS (clear_ip_bgp_as_soft_out,
  4619. clear_ip_bgp_as_out_cmd,
  4620. "clear ip bgp " CMD_AS_RANGE " out",
  4621. CLEAR_STR
  4622. IP_STR
  4623. BGP_STR
  4624. "Clear peers with the AS number\n"
  4625. "Soft reconfig outbound update\n")
  4626. DEFUN (clear_ip_bgp_as_ipv4_soft_out,
  4627. clear_ip_bgp_as_ipv4_soft_out_cmd,
  4628. "clear ip bgp " CMD_AS_RANGE " ipv4 (unicast|multicast) soft out",
  4629. CLEAR_STR
  4630. IP_STR
  4631. BGP_STR
  4632. "Clear peers with the AS number\n"
  4633. "Address family\n"
  4634. "Address Family modifier\n"
  4635. "Address Family modifier\n"
  4636. "Soft reconfig\n"
  4637. "Soft reconfig outbound update\n")
  4638. {
  4639. if (strncmp (argv[1], "m", 1) == 0)
  4640. return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_as,
  4641. BGP_CLEAR_SOFT_OUT, argv[0]);
  4642. return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as,
  4643. BGP_CLEAR_SOFT_OUT, argv[0]);
  4644. }
  4645. ALIAS (clear_ip_bgp_as_ipv4_soft_out,
  4646. clear_ip_bgp_as_ipv4_out_cmd,
  4647. "clear ip bgp " CMD_AS_RANGE " ipv4 (unicast|multicast) out",
  4648. CLEAR_STR
  4649. IP_STR
  4650. BGP_STR
  4651. "Clear peers with the AS number\n"
  4652. "Address family\n"
  4653. "Address Family modifier\n"
  4654. "Address Family modifier\n"
  4655. "Soft reconfig outbound update\n")
  4656. DEFUN (clear_ip_bgp_as_vpnv4_soft_out,
  4657. clear_ip_bgp_as_vpnv4_soft_out_cmd,
  4658. "clear ip bgp " CMD_AS_RANGE " vpnv4 unicast soft out",
  4659. CLEAR_STR
  4660. IP_STR
  4661. BGP_STR
  4662. "Clear peers with the AS number\n"
  4663. "Address family\n"
  4664. "Address Family modifier\n"
  4665. "Soft reconfig\n"
  4666. "Soft reconfig outbound update\n")
  4667. {
  4668. return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_as,
  4669. BGP_CLEAR_SOFT_OUT, argv[0]);
  4670. }
  4671. ALIAS (clear_ip_bgp_as_vpnv4_soft_out,
  4672. clear_ip_bgp_as_vpnv4_out_cmd,
  4673. "clear ip bgp " CMD_AS_RANGE " vpnv4 unicast out",
  4674. CLEAR_STR
  4675. IP_STR
  4676. BGP_STR
  4677. "Clear peers with the AS number\n"
  4678. "Address family\n"
  4679. "Address Family modifier\n"
  4680. "Soft reconfig outbound update\n")
  4681. DEFUN (clear_ip_bgp_as_encap_soft_out,
  4682. clear_ip_bgp_as_encap_soft_out_cmd,
  4683. "clear ip bgp " CMD_AS_RANGE " encap unicast soft out",
  4684. CLEAR_STR
  4685. IP_STR
  4686. BGP_STR
  4687. "Clear peers with the AS number\n"
  4688. "Address family\n"
  4689. "Address Family modifier\n"
  4690. "Soft reconfig\n"
  4691. "Soft reconfig outbound update\n")
  4692. {
  4693. return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_ENCAP, clear_as,
  4694. BGP_CLEAR_SOFT_OUT, argv[0]);
  4695. }
  4696. ALIAS (clear_ip_bgp_as_encap_soft_out,
  4697. clear_ip_bgp_as_encap_out_cmd,
  4698. "clear ip bgp " CMD_AS_RANGE " encap unicast out",
  4699. CLEAR_STR
  4700. IP_STR
  4701. BGP_STR
  4702. "Clear peers with the AS number\n"
  4703. "Address family\n"
  4704. "Address Family modifier\n"
  4705. "Soft reconfig outbound update\n")
  4706. DEFUN (clear_bgp_as_soft_out,
  4707. clear_bgp_as_soft_out_cmd,
  4708. "clear bgp " CMD_AS_RANGE " soft out",
  4709. CLEAR_STR
  4710. BGP_STR
  4711. "Clear peers with the AS number\n"
  4712. "Soft reconfig\n"
  4713. "Soft reconfig outbound update\n")
  4714. {
  4715. return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_as,
  4716. BGP_CLEAR_SOFT_OUT, argv[0]);
  4717. }
  4718. ALIAS (clear_bgp_as_soft_out,
  4719. clear_bgp_ipv6_as_soft_out_cmd,
  4720. "clear bgp ipv6 " CMD_AS_RANGE " soft out",
  4721. CLEAR_STR
  4722. BGP_STR
  4723. "Address family\n"
  4724. "Clear peers with the AS number\n"
  4725. "Soft reconfig\n"
  4726. "Soft reconfig outbound update\n")
  4727. ALIAS (clear_bgp_as_soft_out,
  4728. clear_bgp_as_out_cmd,
  4729. "clear bgp " CMD_AS_RANGE " out",
  4730. CLEAR_STR
  4731. BGP_STR
  4732. "Clear peers with the AS number\n"
  4733. "Soft reconfig outbound update\n")
  4734. ALIAS (clear_bgp_as_soft_out,
  4735. clear_bgp_ipv6_as_out_cmd,
  4736. "clear bgp ipv6 " CMD_AS_RANGE " out",
  4737. CLEAR_STR
  4738. BGP_STR
  4739. "Address family\n"
  4740. "Clear peers with the AS number\n"
  4741. "Soft reconfig outbound update\n")
  4742. /* Inbound soft-reconfiguration */
  4743. DEFUN (clear_ip_bgp_all_soft_in,
  4744. clear_ip_bgp_all_soft_in_cmd,
  4745. "clear ip bgp * soft in",
  4746. CLEAR_STR
  4747. IP_STR
  4748. BGP_STR
  4749. "Clear all peers\n"
  4750. "Soft reconfig\n"
  4751. "Soft reconfig inbound update\n")
  4752. {
  4753. if (argc == 1)
  4754. return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, clear_all,
  4755. BGP_CLEAR_SOFT_IN, NULL);
  4756. return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
  4757. BGP_CLEAR_SOFT_IN, NULL);
  4758. }
  4759. ALIAS (clear_ip_bgp_all_soft_in,
  4760. clear_ip_bgp_instance_all_soft_in_cmd,
  4761. "clear ip bgp view WORD * soft in",
  4762. CLEAR_STR
  4763. IP_STR
  4764. BGP_STR
  4765. "BGP view\n"
  4766. "view name\n"
  4767. "Clear all peers\n"
  4768. "Soft reconfig\n"
  4769. "Soft reconfig inbound update\n")
  4770. ALIAS (clear_ip_bgp_all_soft_in,
  4771. clear_ip_bgp_all_in_cmd,
  4772. "clear ip bgp * in",
  4773. CLEAR_STR
  4774. IP_STR
  4775. BGP_STR
  4776. "Clear all peers\n"
  4777. "Soft reconfig inbound update\n")
  4778. DEFUN (clear_ip_bgp_all_in_prefix_filter,
  4779. clear_ip_bgp_all_in_prefix_filter_cmd,
  4780. "clear ip bgp * in prefix-filter",
  4781. CLEAR_STR
  4782. IP_STR
  4783. BGP_STR
  4784. "Clear all peers\n"
  4785. "Soft reconfig inbound update\n"
  4786. "Push out prefix-list ORF and do inbound soft reconfig\n")
  4787. {
  4788. if (argc== 1)
  4789. return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, clear_all,
  4790. BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
  4791. return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
  4792. BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
  4793. }
  4794. ALIAS (clear_ip_bgp_all_in_prefix_filter,
  4795. clear_ip_bgp_instance_all_in_prefix_filter_cmd,
  4796. "clear ip bgp view WORD * in prefix-filter",
  4797. CLEAR_STR
  4798. IP_STR
  4799. BGP_STR
  4800. "BGP view\n"
  4801. "view name\n"
  4802. "Clear all peers\n"
  4803. "Soft reconfig inbound update\n"
  4804. "Push out prefix-list ORF and do inbound soft reconfig\n")
  4805. DEFUN (clear_ip_bgp_all_ipv4_soft_in,
  4806. clear_ip_bgp_all_ipv4_soft_in_cmd,
  4807. "clear ip bgp * ipv4 (unicast|multicast) soft in",
  4808. CLEAR_STR
  4809. IP_STR
  4810. BGP_STR
  4811. "Clear all peers\n"
  4812. "Address family\n"
  4813. "Address Family modifier\n"
  4814. "Address Family modifier\n"
  4815. "Soft reconfig\n"
  4816. "Soft reconfig inbound update\n")
  4817. {
  4818. if (strncmp (argv[0], "m", 1) == 0)
  4819. return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_all,
  4820. BGP_CLEAR_SOFT_IN, NULL);
  4821. return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
  4822. BGP_CLEAR_SOFT_IN, NULL);
  4823. }
  4824. ALIAS (clear_ip_bgp_all_ipv4_soft_in,
  4825. clear_ip_bgp_all_ipv4_in_cmd,
  4826. "clear ip bgp * ipv4 (unicast|multicast) in",
  4827. CLEAR_STR
  4828. IP_STR
  4829. BGP_STR
  4830. "Clear all peers\n"
  4831. "Address family\n"
  4832. "Address Family modifier\n"
  4833. "Address Family modifier\n"
  4834. "Soft reconfig inbound update\n")
  4835. DEFUN (clear_ip_bgp_instance_all_ipv4_soft_in,
  4836. clear_ip_bgp_instance_all_ipv4_soft_in_cmd,
  4837. "clear ip bgp view WORD * ipv4 (unicast|multicast) soft in",
  4838. CLEAR_STR
  4839. IP_STR
  4840. BGP_STR
  4841. "BGP view\n"
  4842. "view name\n"
  4843. "Clear all peers\n"
  4844. "Address family\n"
  4845. "Address Family modifier\n"
  4846. "Address Family modifier\n"
  4847. "Soft reconfig\n"
  4848. "Soft reconfig inbound update\n")
  4849. {
  4850. if (strncmp (argv[1], "m", 1) == 0)
  4851. return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_MULTICAST, clear_all,
  4852. BGP_CLEAR_SOFT_IN, NULL);
  4853. return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, clear_all,
  4854. BGP_CLEAR_SOFT_IN, NULL);
  4855. }
  4856. DEFUN (clear_ip_bgp_all_ipv4_in_prefix_filter,
  4857. clear_ip_bgp_all_ipv4_in_prefix_filter_cmd,
  4858. "clear ip bgp * ipv4 (unicast|multicast) in prefix-filter",
  4859. CLEAR_STR
  4860. IP_STR
  4861. BGP_STR
  4862. "Clear all peers\n"
  4863. "Address family\n"
  4864. "Address Family modifier\n"
  4865. "Address Family modifier\n"
  4866. "Soft reconfig inbound update\n"
  4867. "Push out prefix-list ORF and do inbound soft reconfig\n")
  4868. {
  4869. if (strncmp (argv[0], "m", 1) == 0)
  4870. return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_all,
  4871. BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
  4872. return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
  4873. BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
  4874. }
  4875. DEFUN (clear_ip_bgp_instance_all_ipv4_in_prefix_filter,
  4876. clear_ip_bgp_instance_all_ipv4_in_prefix_filter_cmd,
  4877. "clear ip bgp view WORD * ipv4 (unicast|multicast) in prefix-filter",
  4878. CLEAR_STR
  4879. IP_STR
  4880. BGP_STR
  4881. "Clear all peers\n"
  4882. "Address family\n"
  4883. "Address Family modifier\n"
  4884. "Address Family modifier\n"
  4885. "Soft reconfig inbound update\n"
  4886. "Push out prefix-list ORF and do inbound soft reconfig\n")
  4887. {
  4888. if (strncmp (argv[1], "m", 1) == 0)
  4889. return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_MULTICAST, clear_all,
  4890. BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
  4891. return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, clear_all,
  4892. BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
  4893. }
  4894. DEFUN (clear_ip_bgp_all_vpnv4_soft_in,
  4895. clear_ip_bgp_all_vpnv4_soft_in_cmd,
  4896. "clear ip bgp * vpnv4 unicast soft in",
  4897. CLEAR_STR
  4898. IP_STR
  4899. BGP_STR
  4900. "Clear all peers\n"
  4901. "Address family\n"
  4902. "Address Family Modifier\n"
  4903. "Soft reconfig\n"
  4904. "Soft reconfig inbound update\n")
  4905. {
  4906. return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_all,
  4907. BGP_CLEAR_SOFT_IN, NULL);
  4908. }
  4909. ALIAS (clear_ip_bgp_all_vpnv4_soft_in,
  4910. clear_ip_bgp_all_vpnv4_in_cmd,
  4911. "clear ip bgp * vpnv4 unicast in",
  4912. CLEAR_STR
  4913. IP_STR
  4914. BGP_STR
  4915. "Clear all peers\n"
  4916. "Address family\n"
  4917. "Address Family Modifier\n"
  4918. "Soft reconfig inbound update\n")
  4919. DEFUN (clear_ip_bgp_all_encap_soft_in,
  4920. clear_ip_bgp_all_encap_soft_in_cmd,
  4921. "clear ip bgp * encap unicast soft in",
  4922. CLEAR_STR
  4923. IP_STR
  4924. BGP_STR
  4925. "Clear all peers\n"
  4926. "Address family\n"
  4927. "Address Family Modifier\n"
  4928. "Soft reconfig\n"
  4929. "Soft reconfig inbound update\n")
  4930. {
  4931. return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_ENCAP, clear_all,
  4932. BGP_CLEAR_SOFT_IN, NULL);
  4933. }
  4934. ALIAS (clear_ip_bgp_all_encap_soft_in,
  4935. clear_ip_bgp_all_encap_in_cmd,
  4936. "clear ip bgp * encap unicast in",
  4937. CLEAR_STR
  4938. IP_STR
  4939. BGP_STR
  4940. "Clear all peers\n"
  4941. "Address family\n"
  4942. "Address Family Modifier\n"
  4943. "Soft reconfig inbound update\n")
  4944. DEFUN (clear_bgp_all_soft_in,
  4945. clear_bgp_all_soft_in_cmd,
  4946. "clear bgp * soft in",
  4947. CLEAR_STR
  4948. BGP_STR
  4949. "Clear all peers\n"
  4950. "Soft reconfig\n"
  4951. "Soft reconfig inbound update\n")
  4952. {
  4953. if (argc == 1)
  4954. return bgp_clear_vty (vty, argv[0], AFI_IP6, SAFI_UNICAST, clear_all,
  4955. BGP_CLEAR_SOFT_IN, NULL);
  4956. return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_all,
  4957. BGP_CLEAR_SOFT_IN, NULL);
  4958. }
  4959. ALIAS (clear_bgp_all_soft_in,
  4960. clear_bgp_instance_all_soft_in_cmd,
  4961. "clear bgp view WORD * soft in",
  4962. CLEAR_STR
  4963. BGP_STR
  4964. "BGP view\n"
  4965. "view name\n"
  4966. "Clear all peers\n"
  4967. "Soft reconfig\n"
  4968. "Soft reconfig inbound update\n")
  4969. ALIAS (clear_bgp_all_soft_in,
  4970. clear_bgp_ipv6_all_soft_in_cmd,
  4971. "clear bgp ipv6 * soft in",
  4972. CLEAR_STR
  4973. BGP_STR
  4974. "Address family\n"
  4975. "Clear all peers\n"
  4976. "Soft reconfig\n"
  4977. "Soft reconfig inbound update\n")
  4978. ALIAS (clear_bgp_all_soft_in,
  4979. clear_bgp_all_in_cmd,
  4980. "clear bgp * in",
  4981. CLEAR_STR
  4982. BGP_STR
  4983. "Clear all peers\n"
  4984. "Soft reconfig inbound update\n")
  4985. ALIAS (clear_bgp_all_soft_in,
  4986. clear_bgp_ipv6_all_in_cmd,
  4987. "clear bgp ipv6 * in",
  4988. CLEAR_STR
  4989. BGP_STR
  4990. "Address family\n"
  4991. "Clear all peers\n"
  4992. "Soft reconfig inbound update\n")
  4993. DEFUN (clear_bgp_all_in_prefix_filter,
  4994. clear_bgp_all_in_prefix_filter_cmd,
  4995. "clear bgp * in prefix-filter",
  4996. CLEAR_STR
  4997. BGP_STR
  4998. "Clear all peers\n"
  4999. "Soft reconfig inbound update\n"
  5000. "Push out prefix-list ORF and do inbound soft reconfig\n")
  5001. {
  5002. return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_all,
  5003. BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
  5004. }
  5005. ALIAS (clear_bgp_all_in_prefix_filter,
  5006. clear_bgp_ipv6_all_in_prefix_filter_cmd,
  5007. "clear bgp ipv6 * in prefix-filter",
  5008. CLEAR_STR
  5009. BGP_STR
  5010. "Address family\n"
  5011. "Clear all peers\n"
  5012. "Soft reconfig inbound update\n"
  5013. "Push out prefix-list ORF and do inbound soft reconfig\n")
  5014. DEFUN (clear_ip_bgp_peer_soft_in,
  5015. clear_ip_bgp_peer_soft_in_cmd,
  5016. "clear ip bgp A.B.C.D soft in",
  5017. CLEAR_STR
  5018. IP_STR
  5019. BGP_STR
  5020. "BGP neighbor address to clear\n"
  5021. "Soft reconfig\n"
  5022. "Soft reconfig inbound update\n")
  5023. {
  5024. return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
  5025. BGP_CLEAR_SOFT_IN, argv[0]);
  5026. }
  5027. ALIAS (clear_ip_bgp_peer_soft_in,
  5028. clear_ip_bgp_peer_in_cmd,
  5029. "clear ip bgp A.B.C.D in",
  5030. CLEAR_STR
  5031. IP_STR
  5032. BGP_STR
  5033. "BGP neighbor address to clear\n"
  5034. "Soft reconfig inbound update\n")
  5035. DEFUN (clear_ip_bgp_peer_in_prefix_filter,
  5036. clear_ip_bgp_peer_in_prefix_filter_cmd,
  5037. "clear ip bgp A.B.C.D in prefix-filter",
  5038. CLEAR_STR
  5039. IP_STR
  5040. BGP_STR
  5041. "BGP neighbor address to clear\n"
  5042. "Soft reconfig inbound update\n"
  5043. "Push out the existing ORF prefix-list\n")
  5044. {
  5045. return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
  5046. BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
  5047. }
  5048. DEFUN (clear_ip_bgp_peer_ipv4_soft_in,
  5049. clear_ip_bgp_peer_ipv4_soft_in_cmd,
  5050. "clear ip bgp A.B.C.D ipv4 (unicast|multicast) soft in",
  5051. CLEAR_STR
  5052. IP_STR
  5053. BGP_STR
  5054. "BGP neighbor address to clear\n"
  5055. "Address family\n"
  5056. "Address Family modifier\n"
  5057. "Address Family modifier\n"
  5058. "Soft reconfig\n"
  5059. "Soft reconfig inbound update\n")
  5060. {
  5061. if (strncmp (argv[1], "m", 1) == 0)
  5062. return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_peer,
  5063. BGP_CLEAR_SOFT_IN, argv[0]);
  5064. return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
  5065. BGP_CLEAR_SOFT_IN, argv[0]);
  5066. }
  5067. ALIAS (clear_ip_bgp_peer_ipv4_soft_in,
  5068. clear_ip_bgp_peer_ipv4_in_cmd,
  5069. "clear ip bgp A.B.C.D ipv4 (unicast|multicast) in",
  5070. CLEAR_STR
  5071. IP_STR
  5072. BGP_STR
  5073. "BGP neighbor address to clear\n"
  5074. "Address family\n"
  5075. "Address Family modifier\n"
  5076. "Address Family modifier\n"
  5077. "Soft reconfig inbound update\n")
  5078. DEFUN (clear_ip_bgp_peer_ipv4_in_prefix_filter,
  5079. clear_ip_bgp_peer_ipv4_in_prefix_filter_cmd,
  5080. "clear ip bgp A.B.C.D ipv4 (unicast|multicast) in prefix-filter",
  5081. CLEAR_STR
  5082. IP_STR
  5083. BGP_STR
  5084. "BGP neighbor address to clear\n"
  5085. "Address family\n"
  5086. "Address Family modifier\n"
  5087. "Address Family modifier\n"
  5088. "Soft reconfig inbound update\n"
  5089. "Push out the existing ORF prefix-list\n")
  5090. {
  5091. if (strncmp (argv[1], "m", 1) == 0)
  5092. return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_peer,
  5093. BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
  5094. return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
  5095. BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
  5096. }
  5097. DEFUN (clear_ip_bgp_peer_vpnv4_soft_in,
  5098. clear_ip_bgp_peer_vpnv4_soft_in_cmd,
  5099. "clear ip bgp A.B.C.D vpnv4 unicast soft in",
  5100. CLEAR_STR
  5101. IP_STR
  5102. BGP_STR
  5103. "BGP neighbor address to clear\n"
  5104. "Address family\n"
  5105. "Address Family Modifier\n"
  5106. "Soft reconfig\n"
  5107. "Soft reconfig inbound update\n")
  5108. {
  5109. return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_peer,
  5110. BGP_CLEAR_SOFT_IN, argv[0]);
  5111. }
  5112. ALIAS (clear_ip_bgp_peer_vpnv4_soft_in,
  5113. clear_ip_bgp_peer_vpnv4_in_cmd,
  5114. "clear ip bgp A.B.C.D vpnv4 unicast in",
  5115. CLEAR_STR
  5116. IP_STR
  5117. BGP_STR
  5118. "BGP neighbor address to clear\n"
  5119. "Address family\n"
  5120. "Address Family Modifier\n"
  5121. "Soft reconfig inbound update\n")
  5122. DEFUN (clear_ip_bgp_peer_encap_soft_in,
  5123. clear_ip_bgp_peer_encap_soft_in_cmd,
  5124. "clear ip bgp A.B.C.D encap unicast soft in",
  5125. CLEAR_STR
  5126. IP_STR
  5127. BGP_STR
  5128. "BGP neighbor address to clear\n"
  5129. "Address family\n"
  5130. "Address Family Modifier\n"
  5131. "Soft reconfig\n"
  5132. "Soft reconfig inbound update\n")
  5133. {
  5134. return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_ENCAP, clear_peer,
  5135. BGP_CLEAR_SOFT_IN, argv[0]);
  5136. }
  5137. ALIAS (clear_ip_bgp_peer_encap_soft_in,
  5138. clear_ip_bgp_peer_encap_in_cmd,
  5139. "clear ip bgp A.B.C.D encap unicast in",
  5140. CLEAR_STR
  5141. IP_STR
  5142. BGP_STR
  5143. "BGP neighbor address to clear\n"
  5144. "Address family\n"
  5145. "Address Family Modifier\n"
  5146. "Soft reconfig inbound update\n")
  5147. DEFUN (clear_bgp_peer_soft_in,
  5148. clear_bgp_peer_soft_in_cmd,
  5149. "clear bgp (A.B.C.D|X:X::X:X) soft in",
  5150. CLEAR_STR
  5151. BGP_STR
  5152. "BGP neighbor address to clear\n"
  5153. "BGP IPv6 neighbor to clear\n"
  5154. "Soft reconfig\n"
  5155. "Soft reconfig inbound update\n")
  5156. {
  5157. return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_peer,
  5158. BGP_CLEAR_SOFT_IN, argv[0]);
  5159. }
  5160. ALIAS (clear_bgp_peer_soft_in,
  5161. clear_bgp_ipv6_peer_soft_in_cmd,
  5162. "clear bgp ipv6 (A.B.C.D|X:X::X:X) soft in",
  5163. CLEAR_STR
  5164. BGP_STR
  5165. "Address family\n"
  5166. "BGP neighbor address to clear\n"
  5167. "BGP IPv6 neighbor to clear\n"
  5168. "Soft reconfig\n"
  5169. "Soft reconfig inbound update\n")
  5170. ALIAS (clear_bgp_peer_soft_in,
  5171. clear_bgp_peer_in_cmd,
  5172. "clear bgp (A.B.C.D|X:X::X:X) in",
  5173. CLEAR_STR
  5174. BGP_STR
  5175. "BGP neighbor address to clear\n"
  5176. "BGP IPv6 neighbor to clear\n"
  5177. "Soft reconfig inbound update\n")
  5178. ALIAS (clear_bgp_peer_soft_in,
  5179. clear_bgp_ipv6_peer_in_cmd,
  5180. "clear bgp ipv6 (A.B.C.D|X:X::X:X) in",
  5181. CLEAR_STR
  5182. BGP_STR
  5183. "Address family\n"
  5184. "BGP neighbor address to clear\n"
  5185. "BGP IPv6 neighbor to clear\n"
  5186. "Soft reconfig inbound update\n")
  5187. DEFUN (clear_bgp_peer_in_prefix_filter,
  5188. clear_bgp_peer_in_prefix_filter_cmd,
  5189. "clear bgp (A.B.C.D|X:X::X:X) in prefix-filter",
  5190. CLEAR_STR
  5191. BGP_STR
  5192. "BGP neighbor address to clear\n"
  5193. "BGP IPv6 neighbor to clear\n"
  5194. "Soft reconfig inbound update\n"
  5195. "Push out the existing ORF prefix-list\n")
  5196. {
  5197. return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_peer,
  5198. BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
  5199. }
  5200. ALIAS (clear_bgp_peer_in_prefix_filter,
  5201. clear_bgp_ipv6_peer_in_prefix_filter_cmd,
  5202. "clear bgp ipv6 (A.B.C.D|X:X::X:X) in prefix-filter",
  5203. CLEAR_STR
  5204. BGP_STR
  5205. "Address family\n"
  5206. "BGP neighbor address to clear\n"
  5207. "BGP IPv6 neighbor to clear\n"
  5208. "Soft reconfig inbound update\n"
  5209. "Push out the existing ORF prefix-list\n")
  5210. DEFUN (clear_ip_bgp_peer_group_soft_in,
  5211. clear_ip_bgp_peer_group_soft_in_cmd,
  5212. "clear ip bgp peer-group WORD soft in",
  5213. CLEAR_STR
  5214. IP_STR
  5215. BGP_STR
  5216. "Clear all members of peer-group\n"
  5217. "BGP peer-group name\n"
  5218. "Soft reconfig\n"
  5219. "Soft reconfig inbound update\n")
  5220. {
  5221. return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
  5222. BGP_CLEAR_SOFT_IN, argv[0]);
  5223. }
  5224. ALIAS (clear_ip_bgp_peer_group_soft_in,
  5225. clear_ip_bgp_peer_group_in_cmd,
  5226. "clear ip bgp peer-group WORD in",
  5227. CLEAR_STR
  5228. IP_STR
  5229. BGP_STR
  5230. "Clear all members of peer-group\n"
  5231. "BGP peer-group name\n"
  5232. "Soft reconfig inbound update\n")
  5233. DEFUN (clear_ip_bgp_peer_group_in_prefix_filter,
  5234. clear_ip_bgp_peer_group_in_prefix_filter_cmd,
  5235. "clear ip bgp peer-group WORD in prefix-filter",
  5236. CLEAR_STR
  5237. IP_STR
  5238. BGP_STR
  5239. "Clear all members of peer-group\n"
  5240. "BGP peer-group name\n"
  5241. "Soft reconfig inbound update\n"
  5242. "Push out prefix-list ORF and do inbound soft reconfig\n")
  5243. {
  5244. return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
  5245. BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
  5246. }
  5247. DEFUN (clear_ip_bgp_peer_group_ipv4_soft_in,
  5248. clear_ip_bgp_peer_group_ipv4_soft_in_cmd,
  5249. "clear ip bgp peer-group WORD ipv4 (unicast|multicast) soft in",
  5250. CLEAR_STR
  5251. IP_STR
  5252. BGP_STR
  5253. "Clear all members of peer-group\n"
  5254. "BGP peer-group name\n"
  5255. "Address family\n"
  5256. "Address Family modifier\n"
  5257. "Address Family modifier\n"
  5258. "Soft reconfig\n"
  5259. "Soft reconfig inbound update\n")
  5260. {
  5261. if (strncmp (argv[1], "m", 1) == 0)
  5262. return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_group,
  5263. BGP_CLEAR_SOFT_IN, argv[0]);
  5264. return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
  5265. BGP_CLEAR_SOFT_IN, argv[0]);
  5266. }
  5267. ALIAS (clear_ip_bgp_peer_group_ipv4_soft_in,
  5268. clear_ip_bgp_peer_group_ipv4_in_cmd,
  5269. "clear ip bgp peer-group WORD ipv4 (unicast|multicast) in",
  5270. CLEAR_STR
  5271. IP_STR
  5272. BGP_STR
  5273. "Clear all members of peer-group\n"
  5274. "BGP peer-group name\n"
  5275. "Address family\n"
  5276. "Address Family modifier\n"
  5277. "Address Family modifier\n"
  5278. "Soft reconfig inbound update\n")
  5279. DEFUN (clear_ip_bgp_peer_group_ipv4_in_prefix_filter,
  5280. clear_ip_bgp_peer_group_ipv4_in_prefix_filter_cmd,
  5281. "clear ip bgp peer-group WORD ipv4 (unicast|multicast) in prefix-filter",
  5282. CLEAR_STR
  5283. IP_STR
  5284. BGP_STR
  5285. "Clear all members of peer-group\n"
  5286. "BGP peer-group name\n"
  5287. "Address family\n"
  5288. "Address Family modifier\n"
  5289. "Address Family modifier\n"
  5290. "Soft reconfig inbound update\n"
  5291. "Push out prefix-list ORF and do inbound soft reconfig\n")
  5292. {
  5293. if (strncmp (argv[1], "m", 1) == 0)
  5294. return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_group,
  5295. BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
  5296. return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
  5297. BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
  5298. }
  5299. DEFUN (clear_bgp_peer_group_soft_in,
  5300. clear_bgp_peer_group_soft_in_cmd,
  5301. "clear bgp peer-group WORD soft in",
  5302. CLEAR_STR
  5303. BGP_STR
  5304. "Clear all members of peer-group\n"
  5305. "BGP peer-group name\n"
  5306. "Soft reconfig\n"
  5307. "Soft reconfig inbound update\n")
  5308. {
  5309. return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_group,
  5310. BGP_CLEAR_SOFT_IN, argv[0]);
  5311. }
  5312. ALIAS (clear_bgp_peer_group_soft_in,
  5313. clear_bgp_ipv6_peer_group_soft_in_cmd,
  5314. "clear bgp ipv6 peer-group WORD soft in",
  5315. CLEAR_STR
  5316. BGP_STR
  5317. "Address family\n"
  5318. "Clear all members of peer-group\n"
  5319. "BGP peer-group name\n"
  5320. "Soft reconfig\n"
  5321. "Soft reconfig inbound update\n")
  5322. ALIAS (clear_bgp_peer_group_soft_in,
  5323. clear_bgp_peer_group_in_cmd,
  5324. "clear bgp peer-group WORD in",
  5325. CLEAR_STR
  5326. BGP_STR
  5327. "Clear all members of peer-group\n"
  5328. "BGP peer-group name\n"
  5329. "Soft reconfig inbound update\n")
  5330. ALIAS (clear_bgp_peer_group_soft_in,
  5331. clear_bgp_ipv6_peer_group_in_cmd,
  5332. "clear bgp ipv6 peer-group WORD in",
  5333. CLEAR_STR
  5334. BGP_STR
  5335. "Address family\n"
  5336. "Clear all members of peer-group\n"
  5337. "BGP peer-group name\n"
  5338. "Soft reconfig inbound update\n")
  5339. DEFUN (clear_bgp_peer_group_in_prefix_filter,
  5340. clear_bgp_peer_group_in_prefix_filter_cmd,
  5341. "clear bgp peer-group WORD in prefix-filter",
  5342. CLEAR_STR
  5343. BGP_STR
  5344. "Clear all members of peer-group\n"
  5345. "BGP peer-group name\n"
  5346. "Soft reconfig inbound update\n"
  5347. "Push out prefix-list ORF and do inbound soft reconfig\n")
  5348. {
  5349. return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_group,
  5350. BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
  5351. }
  5352. ALIAS (clear_bgp_peer_group_in_prefix_filter,
  5353. clear_bgp_ipv6_peer_group_in_prefix_filter_cmd,
  5354. "clear bgp ipv6 peer-group WORD in prefix-filter",
  5355. CLEAR_STR
  5356. BGP_STR
  5357. "Address family\n"
  5358. "Clear all members of peer-group\n"
  5359. "BGP peer-group name\n"
  5360. "Soft reconfig inbound update\n"
  5361. "Push out prefix-list ORF and do inbound soft reconfig\n")
  5362. DEFUN (clear_ip_bgp_external_soft_in,
  5363. clear_ip_bgp_external_soft_in_cmd,
  5364. "clear ip bgp external soft in",
  5365. CLEAR_STR
  5366. IP_STR
  5367. BGP_STR
  5368. "Clear all external peers\n"
  5369. "Soft reconfig\n"
  5370. "Soft reconfig inbound update\n")
  5371. {
  5372. return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
  5373. BGP_CLEAR_SOFT_IN, NULL);
  5374. }
  5375. ALIAS (clear_ip_bgp_external_soft_in,
  5376. clear_ip_bgp_external_in_cmd,
  5377. "clear ip bgp external in",
  5378. CLEAR_STR
  5379. IP_STR
  5380. BGP_STR
  5381. "Clear all external peers\n"
  5382. "Soft reconfig inbound update\n")
  5383. DEFUN (clear_ip_bgp_external_in_prefix_filter,
  5384. clear_ip_bgp_external_in_prefix_filter_cmd,
  5385. "clear ip bgp external in prefix-filter",
  5386. CLEAR_STR
  5387. IP_STR
  5388. BGP_STR
  5389. "Clear all external peers\n"
  5390. "Soft reconfig inbound update\n"
  5391. "Push out prefix-list ORF and do inbound soft reconfig\n")
  5392. {
  5393. return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
  5394. BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
  5395. }
  5396. DEFUN (clear_ip_bgp_external_ipv4_soft_in,
  5397. clear_ip_bgp_external_ipv4_soft_in_cmd,
  5398. "clear ip bgp external ipv4 (unicast|multicast) soft in",
  5399. CLEAR_STR
  5400. IP_STR
  5401. BGP_STR
  5402. "Clear all external peers\n"
  5403. "Address family\n"
  5404. "Address Family modifier\n"
  5405. "Address Family modifier\n"
  5406. "Soft reconfig\n"
  5407. "Soft reconfig inbound update\n")
  5408. {
  5409. if (strncmp (argv[0], "m", 1) == 0)
  5410. return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_external,
  5411. BGP_CLEAR_SOFT_IN, NULL);
  5412. return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
  5413. BGP_CLEAR_SOFT_IN, NULL);
  5414. }
  5415. ALIAS (clear_ip_bgp_external_ipv4_soft_in,
  5416. clear_ip_bgp_external_ipv4_in_cmd,
  5417. "clear ip bgp external ipv4 (unicast|multicast) in",
  5418. CLEAR_STR
  5419. IP_STR
  5420. BGP_STR
  5421. "Clear all external peers\n"
  5422. "Address family\n"
  5423. "Address Family modifier\n"
  5424. "Address Family modifier\n"
  5425. "Soft reconfig inbound update\n")
  5426. DEFUN (clear_ip_bgp_external_ipv4_in_prefix_filter,
  5427. clear_ip_bgp_external_ipv4_in_prefix_filter_cmd,
  5428. "clear ip bgp external ipv4 (unicast|multicast) in prefix-filter",
  5429. CLEAR_STR
  5430. IP_STR
  5431. BGP_STR
  5432. "Clear all external peers\n"
  5433. "Address family\n"
  5434. "Address Family modifier\n"
  5435. "Address Family modifier\n"
  5436. "Soft reconfig inbound update\n"
  5437. "Push out prefix-list ORF and do inbound soft reconfig\n")
  5438. {
  5439. if (strncmp (argv[0], "m", 1) == 0)
  5440. return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_external,
  5441. BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
  5442. return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
  5443. BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
  5444. }
  5445. DEFUN (clear_bgp_external_soft_in,
  5446. clear_bgp_external_soft_in_cmd,
  5447. "clear bgp external soft in",
  5448. CLEAR_STR
  5449. BGP_STR
  5450. "Clear all external peers\n"
  5451. "Soft reconfig\n"
  5452. "Soft reconfig inbound update\n")
  5453. {
  5454. return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_external,
  5455. BGP_CLEAR_SOFT_IN, NULL);
  5456. }
  5457. ALIAS (clear_bgp_external_soft_in,
  5458. clear_bgp_ipv6_external_soft_in_cmd,
  5459. "clear bgp ipv6 external soft in",
  5460. CLEAR_STR
  5461. BGP_STR
  5462. "Address family\n"
  5463. "Clear all external peers\n"
  5464. "Soft reconfig\n"
  5465. "Soft reconfig inbound update\n")
  5466. ALIAS (clear_bgp_external_soft_in,
  5467. clear_bgp_external_in_cmd,
  5468. "clear bgp external in",
  5469. CLEAR_STR
  5470. BGP_STR
  5471. "Clear all external peers\n"
  5472. "Soft reconfig inbound update\n")
  5473. ALIAS (clear_bgp_external_soft_in,
  5474. clear_bgp_ipv6_external_in_cmd,
  5475. "clear bgp ipv6 external WORD in",
  5476. CLEAR_STR
  5477. BGP_STR
  5478. "Address family\n"
  5479. "Clear all external peers\n"
  5480. "Soft reconfig inbound update\n")
  5481. DEFUN (clear_bgp_external_in_prefix_filter,
  5482. clear_bgp_external_in_prefix_filter_cmd,
  5483. "clear bgp external in prefix-filter",
  5484. CLEAR_STR
  5485. BGP_STR
  5486. "Clear all external peers\n"
  5487. "Soft reconfig inbound update\n"
  5488. "Push out prefix-list ORF and do inbound soft reconfig\n")
  5489. {
  5490. return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_external,
  5491. BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
  5492. }
  5493. ALIAS (clear_bgp_external_in_prefix_filter,
  5494. clear_bgp_ipv6_external_in_prefix_filter_cmd,
  5495. "clear bgp ipv6 external in prefix-filter",
  5496. CLEAR_STR
  5497. BGP_STR
  5498. "Address family\n"
  5499. "Clear all external peers\n"
  5500. "Soft reconfig inbound update\n"
  5501. "Push out prefix-list ORF and do inbound soft reconfig\n")
  5502. DEFUN (clear_ip_bgp_as_soft_in,
  5503. clear_ip_bgp_as_soft_in_cmd,
  5504. "clear ip bgp " CMD_AS_RANGE " soft in",
  5505. CLEAR_STR
  5506. IP_STR
  5507. BGP_STR
  5508. "Clear peers with the AS number\n"
  5509. "Soft reconfig\n"
  5510. "Soft reconfig inbound update\n")
  5511. {
  5512. return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as,
  5513. BGP_CLEAR_SOFT_IN, argv[0]);
  5514. }
  5515. ALIAS (clear_ip_bgp_as_soft_in,
  5516. clear_ip_bgp_as_in_cmd,
  5517. "clear ip bgp " CMD_AS_RANGE " in",
  5518. CLEAR_STR
  5519. IP_STR
  5520. BGP_STR
  5521. "Clear peers with the AS number\n"
  5522. "Soft reconfig inbound update\n")
  5523. DEFUN (clear_ip_bgp_as_in_prefix_filter,
  5524. clear_ip_bgp_as_in_prefix_filter_cmd,
  5525. "clear ip bgp " CMD_AS_RANGE " in prefix-filter",
  5526. CLEAR_STR
  5527. IP_STR
  5528. BGP_STR
  5529. "Clear peers with the AS number\n"
  5530. "Soft reconfig inbound update\n"
  5531. "Push out prefix-list ORF and do inbound soft reconfig\n")
  5532. {
  5533. return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as,
  5534. BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
  5535. }
  5536. DEFUN (clear_ip_bgp_as_ipv4_soft_in,
  5537. clear_ip_bgp_as_ipv4_soft_in_cmd,
  5538. "clear ip bgp " CMD_AS_RANGE " ipv4 (unicast|multicast) soft in",
  5539. CLEAR_STR
  5540. IP_STR
  5541. BGP_STR
  5542. "Clear peers with the AS number\n"
  5543. "Address family\n"
  5544. "Address Family modifier\n"
  5545. "Address Family modifier\n"
  5546. "Soft reconfig\n"
  5547. "Soft reconfig inbound update\n")
  5548. {
  5549. if (strncmp (argv[1], "m", 1) == 0)
  5550. return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_as,
  5551. BGP_CLEAR_SOFT_IN, argv[0]);
  5552. return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as,
  5553. BGP_CLEAR_SOFT_IN, argv[0]);
  5554. }
  5555. ALIAS (clear_ip_bgp_as_ipv4_soft_in,
  5556. clear_ip_bgp_as_ipv4_in_cmd,
  5557. "clear ip bgp " CMD_AS_RANGE " ipv4 (unicast|multicast) in",
  5558. CLEAR_STR
  5559. IP_STR
  5560. BGP_STR
  5561. "Clear peers with the AS number\n"
  5562. "Address family\n"
  5563. "Address Family modifier\n"
  5564. "Address Family modifier\n"
  5565. "Soft reconfig inbound update\n")
  5566. DEFUN (clear_ip_bgp_as_ipv4_in_prefix_filter,
  5567. clear_ip_bgp_as_ipv4_in_prefix_filter_cmd,
  5568. "clear ip bgp " CMD_AS_RANGE " ipv4 (unicast|multicast) in prefix-filter",
  5569. CLEAR_STR
  5570. IP_STR
  5571. BGP_STR
  5572. "Clear peers with the AS number\n"
  5573. "Address family\n"
  5574. "Address Family modifier\n"
  5575. "Address Family modifier\n"
  5576. "Soft reconfig inbound update\n"
  5577. "Push out prefix-list ORF and do inbound soft reconfig\n")
  5578. {
  5579. if (strncmp (argv[1], "m", 1) == 0)
  5580. return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_as,
  5581. BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
  5582. return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as,
  5583. BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
  5584. }
  5585. DEFUN (clear_ip_bgp_as_vpnv4_soft_in,
  5586. clear_ip_bgp_as_vpnv4_soft_in_cmd,
  5587. "clear ip bgp " CMD_AS_RANGE " vpnv4 unicast soft in",
  5588. CLEAR_STR
  5589. IP_STR
  5590. BGP_STR
  5591. "Clear peers with the AS number\n"
  5592. "Address family\n"
  5593. "Address Family modifier\n"
  5594. "Soft reconfig\n"
  5595. "Soft reconfig inbound update\n")
  5596. {
  5597. return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_as,
  5598. BGP_CLEAR_SOFT_IN, argv[0]);
  5599. }
  5600. ALIAS (clear_ip_bgp_as_vpnv4_soft_in,
  5601. clear_ip_bgp_as_vpnv4_in_cmd,
  5602. "clear ip bgp " CMD_AS_RANGE " vpnv4 unicast in",
  5603. CLEAR_STR
  5604. IP_STR
  5605. BGP_STR
  5606. "Clear peers with the AS number\n"
  5607. "Address family\n"
  5608. "Address Family modifier\n"
  5609. "Soft reconfig inbound update\n")
  5610. DEFUN (clear_ip_bgp_as_encap_soft_in,
  5611. clear_ip_bgp_as_encap_soft_in_cmd,
  5612. "clear ip bgp " CMD_AS_RANGE " encap unicast soft in",
  5613. CLEAR_STR
  5614. IP_STR
  5615. BGP_STR
  5616. "Clear peers with the AS number\n"
  5617. "Address family\n"
  5618. "Address Family modifier\n"
  5619. "Soft reconfig\n"
  5620. "Soft reconfig inbound update\n")
  5621. {
  5622. return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_ENCAP, clear_as,
  5623. BGP_CLEAR_SOFT_IN, argv[0]);
  5624. }
  5625. ALIAS (clear_ip_bgp_as_encap_soft_in,
  5626. clear_ip_bgp_as_encap_in_cmd,
  5627. "clear ip bgp " CMD_AS_RANGE " encap unicast in",
  5628. CLEAR_STR
  5629. IP_STR
  5630. BGP_STR
  5631. "Clear peers with the AS number\n"
  5632. "Address family\n"
  5633. "Address Family modifier\n"
  5634. "Soft reconfig inbound update\n")
  5635. DEFUN (clear_bgp_as_soft_in,
  5636. clear_bgp_as_soft_in_cmd,
  5637. "clear bgp " CMD_AS_RANGE " soft in",
  5638. CLEAR_STR
  5639. BGP_STR
  5640. "Clear peers with the AS number\n"
  5641. "Soft reconfig\n"
  5642. "Soft reconfig inbound update\n")
  5643. {
  5644. return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_as,
  5645. BGP_CLEAR_SOFT_IN, argv[0]);
  5646. }
  5647. ALIAS (clear_bgp_as_soft_in,
  5648. clear_bgp_ipv6_as_soft_in_cmd,
  5649. "clear bgp ipv6 " CMD_AS_RANGE " soft in",
  5650. CLEAR_STR
  5651. BGP_STR
  5652. "Address family\n"
  5653. "Clear peers with the AS number\n"
  5654. "Soft reconfig\n"
  5655. "Soft reconfig inbound update\n")
  5656. ALIAS (clear_bgp_as_soft_in,
  5657. clear_bgp_as_in_cmd,
  5658. "clear bgp " CMD_AS_RANGE " in",
  5659. CLEAR_STR
  5660. BGP_STR
  5661. "Clear peers with the AS number\n"
  5662. "Soft reconfig inbound update\n")
  5663. ALIAS (clear_bgp_as_soft_in,
  5664. clear_bgp_ipv6_as_in_cmd,
  5665. "clear bgp ipv6 " CMD_AS_RANGE " in",
  5666. CLEAR_STR
  5667. BGP_STR
  5668. "Address family\n"
  5669. "Clear peers with the AS number\n"
  5670. "Soft reconfig inbound update\n")
  5671. DEFUN (clear_bgp_as_in_prefix_filter,
  5672. clear_bgp_as_in_prefix_filter_cmd,
  5673. "clear bgp " CMD_AS_RANGE " in prefix-filter",
  5674. CLEAR_STR
  5675. BGP_STR
  5676. "Clear peers with the AS number\n"
  5677. "Soft reconfig inbound update\n"
  5678. "Push out prefix-list ORF and do inbound soft reconfig\n")
  5679. {
  5680. return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_as,
  5681. BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
  5682. }
  5683. ALIAS (clear_bgp_as_in_prefix_filter,
  5684. clear_bgp_ipv6_as_in_prefix_filter_cmd,
  5685. "clear bgp ipv6 " CMD_AS_RANGE " in prefix-filter",
  5686. CLEAR_STR
  5687. BGP_STR
  5688. "Address family\n"
  5689. "Clear peers with the AS number\n"
  5690. "Soft reconfig inbound update\n"
  5691. "Push out prefix-list ORF and do inbound soft reconfig\n")
  5692. /* Both soft-reconfiguration */
  5693. DEFUN (clear_ip_bgp_all_soft,
  5694. clear_ip_bgp_all_soft_cmd,
  5695. "clear ip bgp * soft",
  5696. CLEAR_STR
  5697. IP_STR
  5698. BGP_STR
  5699. "Clear all peers\n"
  5700. "Soft reconfig\n")
  5701. {
  5702. if (argc == 1)
  5703. return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, clear_all,
  5704. BGP_CLEAR_SOFT_BOTH, NULL);
  5705. return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
  5706. BGP_CLEAR_SOFT_BOTH, NULL);
  5707. }
  5708. ALIAS (clear_ip_bgp_all_soft,
  5709. clear_ip_bgp_instance_all_soft_cmd,
  5710. "clear ip bgp view WORD * soft",
  5711. CLEAR_STR
  5712. IP_STR
  5713. BGP_STR
  5714. "BGP view\n"
  5715. "view name\n"
  5716. "Clear all peers\n"
  5717. "Soft reconfig\n")
  5718. DEFUN (clear_ip_bgp_all_ipv4_soft,
  5719. clear_ip_bgp_all_ipv4_soft_cmd,
  5720. "clear ip bgp * ipv4 (unicast|multicast) soft",
  5721. CLEAR_STR
  5722. IP_STR
  5723. BGP_STR
  5724. "Clear all peers\n"
  5725. "Address family\n"
  5726. "Address Family Modifier\n"
  5727. "Address Family Modifier\n"
  5728. "Soft reconfig\n")
  5729. {
  5730. if (strncmp (argv[0], "m", 1) == 0)
  5731. return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_all,
  5732. BGP_CLEAR_SOFT_BOTH, NULL);
  5733. return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
  5734. BGP_CLEAR_SOFT_BOTH, NULL);
  5735. }
  5736. DEFUN (clear_ip_bgp_instance_all_ipv4_soft,
  5737. clear_ip_bgp_instance_all_ipv4_soft_cmd,
  5738. "clear ip bgp view WORD * ipv4 (unicast|multicast) soft",
  5739. CLEAR_STR
  5740. IP_STR
  5741. BGP_STR
  5742. "BGP view\n"
  5743. "view name\n"
  5744. "Clear all peers\n"
  5745. "Address family\n"
  5746. "Address Family Modifier\n"
  5747. "Address Family Modifier\n"
  5748. "Soft reconfig\n")
  5749. {
  5750. if (strncmp (argv[1], "m", 1) == 0)
  5751. return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_all,
  5752. BGP_CLEAR_SOFT_BOTH, NULL);
  5753. return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
  5754. BGP_CLEAR_SOFT_BOTH, NULL);
  5755. }
  5756. DEFUN (clear_ip_bgp_all_vpnv4_soft,
  5757. clear_ip_bgp_all_vpnv4_soft_cmd,
  5758. "clear ip bgp * vpnv4 unicast soft",
  5759. CLEAR_STR
  5760. IP_STR
  5761. BGP_STR
  5762. "Clear all peers\n"
  5763. "Address family\n"
  5764. "Address Family Modifier\n"
  5765. "Soft reconfig\n")
  5766. {
  5767. return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_all,
  5768. BGP_CLEAR_SOFT_BOTH, argv[0]);
  5769. }
  5770. DEFUN (clear_ip_bgp_all_encap_soft,
  5771. clear_ip_bgp_all_encap_soft_cmd,
  5772. "clear ip bgp * encap unicast soft",
  5773. CLEAR_STR
  5774. IP_STR
  5775. BGP_STR
  5776. "Clear all peers\n"
  5777. "Address family\n"
  5778. "Address Family Modifier\n"
  5779. "Soft reconfig\n")
  5780. {
  5781. return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_ENCAP, clear_all,
  5782. BGP_CLEAR_SOFT_BOTH, argv[0]);
  5783. }
  5784. DEFUN (clear_bgp_all_soft,
  5785. clear_bgp_all_soft_cmd,
  5786. "clear bgp * soft",
  5787. CLEAR_STR
  5788. BGP_STR
  5789. "Clear all peers\n"
  5790. "Soft reconfig\n")
  5791. {
  5792. if (argc == 1)
  5793. return bgp_clear_vty (vty, argv[0], AFI_IP6, SAFI_UNICAST, clear_all,
  5794. BGP_CLEAR_SOFT_BOTH, argv[0]);
  5795. return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_all,
  5796. BGP_CLEAR_SOFT_BOTH, argv[0]);
  5797. }
  5798. ALIAS (clear_bgp_all_soft,
  5799. clear_bgp_instance_all_soft_cmd,
  5800. "clear bgp view WORD * soft",
  5801. CLEAR_STR
  5802. BGP_STR
  5803. "BGP view\n"
  5804. "view name\n"
  5805. "Clear all peers\n"
  5806. "Soft reconfig\n")
  5807. ALIAS (clear_bgp_all_soft,
  5808. clear_bgp_ipv6_all_soft_cmd,
  5809. "clear bgp ipv6 * soft",
  5810. CLEAR_STR
  5811. BGP_STR
  5812. "Address family\n"
  5813. "Clear all peers\n"
  5814. "Soft reconfig\n")
  5815. DEFUN (clear_ip_bgp_peer_soft,
  5816. clear_ip_bgp_peer_soft_cmd,
  5817. "clear ip bgp A.B.C.D soft",
  5818. CLEAR_STR
  5819. IP_STR
  5820. BGP_STR
  5821. "BGP neighbor address to clear\n"
  5822. "Soft reconfig\n")
  5823. {
  5824. return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
  5825. BGP_CLEAR_SOFT_BOTH, argv[0]);
  5826. }
  5827. DEFUN (clear_ip_bgp_peer_ipv4_soft,
  5828. clear_ip_bgp_peer_ipv4_soft_cmd,
  5829. "clear ip bgp A.B.C.D ipv4 (unicast|multicast) soft",
  5830. CLEAR_STR
  5831. IP_STR
  5832. BGP_STR
  5833. "BGP neighbor address to clear\n"
  5834. "Address family\n"
  5835. "Address Family Modifier\n"
  5836. "Address Family Modifier\n"
  5837. "Soft reconfig\n")
  5838. {
  5839. if (strncmp (argv[1], "m", 1) == 0)
  5840. return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_peer,
  5841. BGP_CLEAR_SOFT_BOTH, argv[0]);
  5842. return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
  5843. BGP_CLEAR_SOFT_BOTH, argv[0]);
  5844. }
  5845. DEFUN (clear_ip_bgp_peer_vpnv4_soft,
  5846. clear_ip_bgp_peer_vpnv4_soft_cmd,
  5847. "clear ip bgp A.B.C.D vpnv4 unicast soft",
  5848. CLEAR_STR
  5849. IP_STR
  5850. BGP_STR
  5851. "BGP neighbor address to clear\n"
  5852. "Address family\n"
  5853. "Address Family Modifier\n"
  5854. "Soft reconfig\n")
  5855. {
  5856. return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_peer,
  5857. BGP_CLEAR_SOFT_BOTH, argv[0]);
  5858. }
  5859. DEFUN (clear_ip_bgp_peer_encap_soft,
  5860. clear_ip_bgp_peer_encap_soft_cmd,
  5861. "clear ip bgp A.B.C.D encap unicast soft",
  5862. CLEAR_STR
  5863. IP_STR
  5864. BGP_STR
  5865. "BGP neighbor address to clear\n"
  5866. "Address family\n"
  5867. "Address Family Modifier\n"
  5868. "Soft reconfig\n")
  5869. {
  5870. return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_ENCAP, clear_peer,
  5871. BGP_CLEAR_SOFT_BOTH, argv[0]);
  5872. }
  5873. DEFUN (clear_bgp_peer_soft,
  5874. clear_bgp_peer_soft_cmd,
  5875. "clear bgp (A.B.C.D|X:X::X:X) soft",
  5876. CLEAR_STR
  5877. BGP_STR
  5878. "BGP neighbor address to clear\n"
  5879. "BGP IPv6 neighbor to clear\n"
  5880. "Soft reconfig\n")
  5881. {
  5882. return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_peer,
  5883. BGP_CLEAR_SOFT_BOTH, argv[0]);
  5884. }
  5885. ALIAS (clear_bgp_peer_soft,
  5886. clear_bgp_ipv6_peer_soft_cmd,
  5887. "clear bgp ipv6 (A.B.C.D|X:X::X:X) soft",
  5888. CLEAR_STR
  5889. BGP_STR
  5890. "Address family\n"
  5891. "BGP neighbor address to clear\n"
  5892. "BGP IPv6 neighbor to clear\n"
  5893. "Soft reconfig\n")
  5894. DEFUN (clear_ip_bgp_peer_group_soft,
  5895. clear_ip_bgp_peer_group_soft_cmd,
  5896. "clear ip bgp peer-group WORD soft",
  5897. CLEAR_STR
  5898. IP_STR
  5899. BGP_STR
  5900. "Clear all members of peer-group\n"
  5901. "BGP peer-group name\n"
  5902. "Soft reconfig\n")
  5903. {
  5904. return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
  5905. BGP_CLEAR_SOFT_BOTH, argv[0]);
  5906. }
  5907. DEFUN (clear_ip_bgp_peer_group_ipv4_soft,
  5908. clear_ip_bgp_peer_group_ipv4_soft_cmd,
  5909. "clear ip bgp peer-group WORD ipv4 (unicast|multicast) soft",
  5910. CLEAR_STR
  5911. IP_STR
  5912. BGP_STR
  5913. "Clear all members of peer-group\n"
  5914. "BGP peer-group name\n"
  5915. "Address family\n"
  5916. "Address Family modifier\n"
  5917. "Address Family modifier\n"
  5918. "Soft reconfig\n")
  5919. {
  5920. if (strncmp (argv[1], "m", 1) == 0)
  5921. return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_group,
  5922. BGP_CLEAR_SOFT_BOTH, argv[0]);
  5923. return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
  5924. BGP_CLEAR_SOFT_BOTH, argv[0]);
  5925. }
  5926. DEFUN (clear_bgp_peer_group_soft,
  5927. clear_bgp_peer_group_soft_cmd,
  5928. "clear bgp peer-group WORD soft",
  5929. CLEAR_STR
  5930. BGP_STR
  5931. "Clear all members of peer-group\n"
  5932. "BGP peer-group name\n"
  5933. "Soft reconfig\n")
  5934. {
  5935. return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_group,
  5936. BGP_CLEAR_SOFT_BOTH, argv[0]);
  5937. }
  5938. ALIAS (clear_bgp_peer_group_soft,
  5939. clear_bgp_ipv6_peer_group_soft_cmd,
  5940. "clear bgp ipv6 peer-group WORD soft",
  5941. CLEAR_STR
  5942. BGP_STR
  5943. "Address family\n"
  5944. "Clear all members of peer-group\n"
  5945. "BGP peer-group name\n"
  5946. "Soft reconfig\n")
  5947. DEFUN (clear_ip_bgp_external_soft,
  5948. clear_ip_bgp_external_soft_cmd,
  5949. "clear ip bgp external soft",
  5950. CLEAR_STR
  5951. IP_STR
  5952. BGP_STR
  5953. "Clear all external peers\n"
  5954. "Soft reconfig\n")
  5955. {
  5956. return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
  5957. BGP_CLEAR_SOFT_BOTH, NULL);
  5958. }
  5959. DEFUN (clear_ip_bgp_external_ipv4_soft,
  5960. clear_ip_bgp_external_ipv4_soft_cmd,
  5961. "clear ip bgp external ipv4 (unicast|multicast) soft",
  5962. CLEAR_STR
  5963. IP_STR
  5964. BGP_STR
  5965. "Clear all external peers\n"
  5966. "Address family\n"
  5967. "Address Family modifier\n"
  5968. "Address Family modifier\n"
  5969. "Soft reconfig\n")
  5970. {
  5971. if (strncmp (argv[0], "m", 1) == 0)
  5972. return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_external,
  5973. BGP_CLEAR_SOFT_BOTH, NULL);
  5974. return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
  5975. BGP_CLEAR_SOFT_BOTH, NULL);
  5976. }
  5977. DEFUN (clear_bgp_external_soft,
  5978. clear_bgp_external_soft_cmd,
  5979. "clear bgp external soft",
  5980. CLEAR_STR
  5981. BGP_STR
  5982. "Clear all external peers\n"
  5983. "Soft reconfig\n")
  5984. {
  5985. return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_external,
  5986. BGP_CLEAR_SOFT_BOTH, NULL);
  5987. }
  5988. ALIAS (clear_bgp_external_soft,
  5989. clear_bgp_ipv6_external_soft_cmd,
  5990. "clear bgp ipv6 external soft",
  5991. CLEAR_STR
  5992. BGP_STR
  5993. "Address family\n"
  5994. "Clear all external peers\n"
  5995. "Soft reconfig\n")
  5996. DEFUN (clear_ip_bgp_as_soft,
  5997. clear_ip_bgp_as_soft_cmd,
  5998. "clear ip bgp " CMD_AS_RANGE " soft",
  5999. CLEAR_STR
  6000. IP_STR
  6001. BGP_STR
  6002. "Clear peers with the AS number\n"
  6003. "Soft reconfig\n")
  6004. {
  6005. return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as,
  6006. BGP_CLEAR_SOFT_BOTH, argv[0]);
  6007. }
  6008. DEFUN (clear_ip_bgp_as_ipv4_soft,
  6009. clear_ip_bgp_as_ipv4_soft_cmd,
  6010. "clear ip bgp " CMD_AS_RANGE " ipv4 (unicast|multicast) soft",
  6011. CLEAR_STR
  6012. IP_STR
  6013. BGP_STR
  6014. "Clear peers with the AS number\n"
  6015. "Address family\n"
  6016. "Address Family Modifier\n"
  6017. "Address Family Modifier\n"
  6018. "Soft reconfig\n")
  6019. {
  6020. if (strncmp (argv[1], "m", 1) == 0)
  6021. return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_as,
  6022. BGP_CLEAR_SOFT_BOTH, argv[0]);
  6023. return bgp_clear_vty (vty, NULL,AFI_IP, SAFI_UNICAST, clear_as,
  6024. BGP_CLEAR_SOFT_BOTH, argv[0]);
  6025. }
  6026. DEFUN (clear_ip_bgp_as_vpnv4_soft,
  6027. clear_ip_bgp_as_vpnv4_soft_cmd,
  6028. "clear ip bgp " CMD_AS_RANGE " vpnv4 unicast soft",
  6029. CLEAR_STR
  6030. IP_STR
  6031. BGP_STR
  6032. "Clear peers with the AS number\n"
  6033. "Address family\n"
  6034. "Address Family Modifier\n"
  6035. "Soft reconfig\n")
  6036. {
  6037. return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_as,
  6038. BGP_CLEAR_SOFT_BOTH, argv[0]);
  6039. }
  6040. DEFUN (clear_ip_bgp_as_encap_soft,
  6041. clear_ip_bgp_as_encap_soft_cmd,
  6042. "clear ip bgp " CMD_AS_RANGE " encap unicast soft",
  6043. CLEAR_STR
  6044. IP_STR
  6045. BGP_STR
  6046. "Clear peers with the AS number\n"
  6047. "Address family\n"
  6048. "Address Family Modifier\n"
  6049. "Soft reconfig\n")
  6050. {
  6051. return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_ENCAP, clear_as,
  6052. BGP_CLEAR_SOFT_BOTH, argv[0]);
  6053. }
  6054. DEFUN (clear_bgp_as_soft,
  6055. clear_bgp_as_soft_cmd,
  6056. "clear bgp " CMD_AS_RANGE " soft",
  6057. CLEAR_STR
  6058. BGP_STR
  6059. "Clear peers with the AS number\n"
  6060. "Soft reconfig\n")
  6061. {
  6062. return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_as,
  6063. BGP_CLEAR_SOFT_BOTH, argv[0]);
  6064. }
  6065. ALIAS (clear_bgp_as_soft,
  6066. clear_bgp_ipv6_as_soft_cmd,
  6067. "clear bgp ipv6 " CMD_AS_RANGE " soft",
  6068. CLEAR_STR
  6069. BGP_STR
  6070. "Address family\n"
  6071. "Clear peers with the AS number\n"
  6072. "Soft reconfig\n")
  6073. /* RS-client soft reconfiguration. */
  6074. #ifdef HAVE_IPV6
  6075. DEFUN (clear_bgp_all_rsclient,
  6076. clear_bgp_all_rsclient_cmd,
  6077. "clear bgp * rsclient",
  6078. CLEAR_STR
  6079. BGP_STR
  6080. "Clear all peers\n"
  6081. "Soft reconfig for rsclient RIB\n")
  6082. {
  6083. if (argc == 1)
  6084. return bgp_clear_vty (vty, argv[0], AFI_IP6, SAFI_UNICAST, clear_all,
  6085. BGP_CLEAR_SOFT_RSCLIENT, NULL);
  6086. return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_all,
  6087. BGP_CLEAR_SOFT_RSCLIENT, NULL);
  6088. }
  6089. ALIAS (clear_bgp_all_rsclient,
  6090. clear_bgp_ipv6_all_rsclient_cmd,
  6091. "clear bgp ipv6 * rsclient",
  6092. CLEAR_STR
  6093. BGP_STR
  6094. "Address family\n"
  6095. "Clear all peers\n"
  6096. "Soft reconfig for rsclient RIB\n")
  6097. ALIAS (clear_bgp_all_rsclient,
  6098. clear_bgp_instance_all_rsclient_cmd,
  6099. "clear bgp view WORD * rsclient",
  6100. CLEAR_STR
  6101. BGP_STR
  6102. "BGP view\n"
  6103. "view name\n"
  6104. "Clear all peers\n"
  6105. "Soft reconfig for rsclient RIB\n")
  6106. ALIAS (clear_bgp_all_rsclient,
  6107. clear_bgp_ipv6_instance_all_rsclient_cmd,
  6108. "clear bgp ipv6 view WORD * rsclient",
  6109. CLEAR_STR
  6110. BGP_STR
  6111. "Address family\n"
  6112. "BGP view\n"
  6113. "view name\n"
  6114. "Clear all peers\n"
  6115. "Soft reconfig for rsclient RIB\n")
  6116. #endif /* HAVE_IPV6 */
  6117. DEFUN (clear_ip_bgp_all_rsclient,
  6118. clear_ip_bgp_all_rsclient_cmd,
  6119. "clear ip bgp * rsclient",
  6120. CLEAR_STR
  6121. IP_STR
  6122. BGP_STR
  6123. "Clear all peers\n"
  6124. "Soft reconfig for rsclient RIB\n")
  6125. {
  6126. if (argc == 1)
  6127. return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, clear_all,
  6128. BGP_CLEAR_SOFT_RSCLIENT, NULL);
  6129. return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
  6130. BGP_CLEAR_SOFT_RSCLIENT, NULL);
  6131. }
  6132. ALIAS (clear_ip_bgp_all_rsclient,
  6133. clear_ip_bgp_instance_all_rsclient_cmd,
  6134. "clear ip bgp view WORD * rsclient",
  6135. CLEAR_STR
  6136. IP_STR
  6137. BGP_STR
  6138. "BGP view\n"
  6139. "view name\n"
  6140. "Clear all peers\n"
  6141. "Soft reconfig for rsclient RIB\n")
  6142. #ifdef HAVE_IPV6
  6143. DEFUN (clear_bgp_peer_rsclient,
  6144. clear_bgp_peer_rsclient_cmd,
  6145. "clear bgp (A.B.C.D|X:X::X:X) rsclient",
  6146. CLEAR_STR
  6147. BGP_STR
  6148. "BGP neighbor IP address to clear\n"
  6149. "BGP IPv6 neighbor to clear\n"
  6150. "Soft reconfig for rsclient RIB\n")
  6151. {
  6152. if (argc == 2)
  6153. return bgp_clear_vty (vty, argv[0], AFI_IP6, SAFI_UNICAST, clear_peer,
  6154. BGP_CLEAR_SOFT_RSCLIENT, argv[1]);
  6155. return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_peer,
  6156. BGP_CLEAR_SOFT_RSCLIENT, argv[0]);
  6157. }
  6158. ALIAS (clear_bgp_peer_rsclient,
  6159. clear_bgp_ipv6_peer_rsclient_cmd,
  6160. "clear bgp ipv6 (A.B.C.D|X:X::X:X) rsclient",
  6161. CLEAR_STR
  6162. BGP_STR
  6163. "Address family\n"
  6164. "BGP neighbor IP address to clear\n"
  6165. "BGP IPv6 neighbor to clear\n"
  6166. "Soft reconfig for rsclient RIB\n")
  6167. ALIAS (clear_bgp_peer_rsclient,
  6168. clear_bgp_instance_peer_rsclient_cmd,
  6169. "clear bgp view WORD (A.B.C.D|X:X::X:X) rsclient",
  6170. CLEAR_STR
  6171. BGP_STR
  6172. "BGP view\n"
  6173. "view name\n"
  6174. "BGP neighbor IP address to clear\n"
  6175. "BGP IPv6 neighbor to clear\n"
  6176. "Soft reconfig for rsclient RIB\n")
  6177. ALIAS (clear_bgp_peer_rsclient,
  6178. clear_bgp_ipv6_instance_peer_rsclient_cmd,
  6179. "clear bgp ipv6 view WORD (A.B.C.D|X:X::X:X) rsclient",
  6180. CLEAR_STR
  6181. BGP_STR
  6182. "Address family\n"
  6183. "BGP view\n"
  6184. "view name\n"
  6185. "BGP neighbor IP address to clear\n"
  6186. "BGP IPv6 neighbor to clear\n"
  6187. "Soft reconfig for rsclient RIB\n")
  6188. #endif /* HAVE_IPV6 */
  6189. DEFUN (clear_ip_bgp_peer_rsclient,
  6190. clear_ip_bgp_peer_rsclient_cmd,
  6191. "clear ip bgp (A.B.C.D|X:X::X:X) rsclient",
  6192. CLEAR_STR
  6193. IP_STR
  6194. BGP_STR
  6195. "BGP neighbor IP address to clear\n"
  6196. "BGP IPv6 neighbor to clear\n"
  6197. "Soft reconfig for rsclient RIB\n")
  6198. {
  6199. if (argc == 2)
  6200. return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, clear_peer,
  6201. BGP_CLEAR_SOFT_RSCLIENT, argv[1]);
  6202. return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
  6203. BGP_CLEAR_SOFT_RSCLIENT, argv[0]);
  6204. }
  6205. ALIAS (clear_ip_bgp_peer_rsclient,
  6206. clear_ip_bgp_instance_peer_rsclient_cmd,
  6207. "clear ip bgp view WORD (A.B.C.D|X:X::X:X) rsclient",
  6208. CLEAR_STR
  6209. IP_STR
  6210. BGP_STR
  6211. "BGP view\n"
  6212. "view name\n"
  6213. "BGP neighbor IP address to clear\n"
  6214. "BGP IPv6 neighbor to clear\n"
  6215. "Soft reconfig for rsclient RIB\n")
  6216. DEFUN (show_bgp_views,
  6217. show_bgp_views_cmd,
  6218. "show bgp views",
  6219. SHOW_STR
  6220. BGP_STR
  6221. "Show the defined BGP views\n")
  6222. {
  6223. struct list *inst = bm->bgp;
  6224. struct listnode *node;
  6225. struct bgp *bgp;
  6226. if (!bgp_option_check (BGP_OPT_MULTIPLE_INSTANCE))
  6227. {
  6228. vty_out (vty, "Multiple BGP views are not defined%s", VTY_NEWLINE);
  6229. return CMD_WARNING;
  6230. }
  6231. vty_out (vty, "Defined BGP views:%s", VTY_NEWLINE);
  6232. for (ALL_LIST_ELEMENTS_RO(inst, node, bgp))
  6233. vty_out (vty, "\t%s (AS%u)%s",
  6234. bgp->name ? bgp->name : "(null)",
  6235. bgp->as, VTY_NEWLINE);
  6236. return CMD_SUCCESS;
  6237. }
  6238. DEFUN (show_bgp_memory,
  6239. show_bgp_memory_cmd,
  6240. "show bgp memory",
  6241. SHOW_STR
  6242. BGP_STR
  6243. "Global BGP memory statistics\n")
  6244. {
  6245. char memstrbuf[MTYPE_MEMSTR_LEN];
  6246. unsigned long count;
  6247. /* RIB related usage stats */
  6248. count = mtype_stats_alloc (MTYPE_BGP_NODE);
  6249. vty_out (vty, "%ld RIB nodes, using %s of memory%s", count,
  6250. mtype_memstr (memstrbuf, sizeof (memstrbuf),
  6251. count * sizeof (struct bgp_node)),
  6252. VTY_NEWLINE);
  6253. count = mtype_stats_alloc (MTYPE_BGP_ROUTE);
  6254. vty_out (vty, "%ld BGP routes, using %s of memory%s", count,
  6255. mtype_memstr (memstrbuf, sizeof (memstrbuf),
  6256. count * sizeof (struct bgp_info)),
  6257. VTY_NEWLINE);
  6258. if ((count = mtype_stats_alloc (MTYPE_BGP_ROUTE_EXTRA)))
  6259. vty_out (vty, "%ld BGP route ancillaries, using %s of memory%s", count,
  6260. mtype_memstr (memstrbuf, sizeof (memstrbuf),
  6261. count * sizeof (struct bgp_info_extra)),
  6262. VTY_NEWLINE);
  6263. if ((count = mtype_stats_alloc (MTYPE_BGP_STATIC)))
  6264. vty_out (vty, "%ld Static routes, using %s of memory%s", count,
  6265. mtype_memstr (memstrbuf, sizeof (memstrbuf),
  6266. count * sizeof (struct bgp_static)),
  6267. VTY_NEWLINE);
  6268. /* Adj-In/Out */
  6269. if ((count = mtype_stats_alloc (MTYPE_BGP_ADJ_IN)))
  6270. vty_out (vty, "%ld Adj-In entries, using %s of memory%s", count,
  6271. mtype_memstr (memstrbuf, sizeof (memstrbuf),
  6272. count * sizeof (struct bgp_adj_in)),
  6273. VTY_NEWLINE);
  6274. if ((count = mtype_stats_alloc (MTYPE_BGP_ADJ_OUT)))
  6275. vty_out (vty, "%ld Adj-Out entries, using %s of memory%s", count,
  6276. mtype_memstr (memstrbuf, sizeof (memstrbuf),
  6277. count * sizeof (struct bgp_adj_out)),
  6278. VTY_NEWLINE);
  6279. if ((count = mtype_stats_alloc (MTYPE_BGP_NEXTHOP_CACHE)))
  6280. vty_out (vty, "%ld Nexthop cache entries, using %s of memory%s", count,
  6281. mtype_memstr (memstrbuf, sizeof (memstrbuf),
  6282. count * sizeof (struct bgp_nexthop_cache)),
  6283. VTY_NEWLINE);
  6284. if ((count = mtype_stats_alloc (MTYPE_BGP_DAMP_INFO)))
  6285. vty_out (vty, "%ld Dampening entries, using %s of memory%s", count,
  6286. mtype_memstr (memstrbuf, sizeof (memstrbuf),
  6287. count * sizeof (struct bgp_damp_info)),
  6288. VTY_NEWLINE);
  6289. /* Attributes */
  6290. count = attr_count();
  6291. vty_out (vty, "%ld BGP attributes, using %s of memory%s", count,
  6292. mtype_memstr (memstrbuf, sizeof (memstrbuf),
  6293. count * sizeof(struct attr)),
  6294. VTY_NEWLINE);
  6295. if ((count = mtype_stats_alloc (MTYPE_ATTR_EXTRA)))
  6296. vty_out (vty, "%ld BGP extra attributes, using %s of memory%s", count,
  6297. mtype_memstr (memstrbuf, sizeof (memstrbuf),
  6298. count * sizeof(struct attr_extra)),
  6299. VTY_NEWLINE);
  6300. if ((count = attr_unknown_count()))
  6301. vty_out (vty, "%ld unknown attributes%s", count, VTY_NEWLINE);
  6302. /* AS_PATH attributes */
  6303. count = aspath_count ();
  6304. vty_out (vty, "%ld BGP AS-PATH entries, using %s of memory%s", count,
  6305. mtype_memstr (memstrbuf, sizeof (memstrbuf),
  6306. count * sizeof (struct aspath)),
  6307. VTY_NEWLINE);
  6308. count = mtype_stats_alloc (MTYPE_AS_SEG);
  6309. vty_out (vty, "%ld BGP AS-PATH segments, using %s of memory%s", count,
  6310. mtype_memstr (memstrbuf, sizeof (memstrbuf),
  6311. count * sizeof (struct assegment)),
  6312. VTY_NEWLINE);
  6313. /* Other attributes */
  6314. if ((count = community_count ()))
  6315. vty_out (vty, "%ld BGP community entries, using %s of memory%s", count,
  6316. mtype_memstr (memstrbuf, sizeof (memstrbuf),
  6317. count * sizeof (struct community)),
  6318. VTY_NEWLINE);
  6319. if ((count = mtype_stats_alloc (MTYPE_ECOMMUNITY)))
  6320. vty_out (vty, "%ld BGP community entries, using %s of memory%s", count,
  6321. mtype_memstr (memstrbuf, sizeof (memstrbuf),
  6322. count * sizeof (struct ecommunity)),
  6323. VTY_NEWLINE);
  6324. if ((count = mtype_stats_alloc (MTYPE_CLUSTER)))
  6325. vty_out (vty, "%ld Cluster lists, using %s of memory%s", count,
  6326. mtype_memstr (memstrbuf, sizeof (memstrbuf),
  6327. count * sizeof (struct cluster_list)),
  6328. VTY_NEWLINE);
  6329. /* Peer related usage */
  6330. count = mtype_stats_alloc (MTYPE_BGP_PEER);
  6331. vty_out (vty, "%ld peers, using %s of memory%s", count,
  6332. mtype_memstr (memstrbuf, sizeof (memstrbuf),
  6333. count * sizeof (struct peer)),
  6334. VTY_NEWLINE);
  6335. if ((count = mtype_stats_alloc (MTYPE_PEER_GROUP)))
  6336. vty_out (vty, "%ld peer groups, using %s of memory%s", count,
  6337. mtype_memstr (memstrbuf, sizeof (memstrbuf),
  6338. count * sizeof (struct peer_group)),
  6339. VTY_NEWLINE);
  6340. /* Other */
  6341. if ((count = mtype_stats_alloc (MTYPE_HASH)))
  6342. vty_out (vty, "%ld hash tables, using %s of memory%s", count,
  6343. mtype_memstr (memstrbuf, sizeof (memstrbuf),
  6344. count * sizeof (struct hash)),
  6345. VTY_NEWLINE);
  6346. if ((count = mtype_stats_alloc (MTYPE_HASH_BACKET)))
  6347. vty_out (vty, "%ld hash buckets, using %s of memory%s", count,
  6348. mtype_memstr (memstrbuf, sizeof (memstrbuf),
  6349. count * sizeof (struct hash_backet)),
  6350. VTY_NEWLINE);
  6351. if ((count = mtype_stats_alloc (MTYPE_BGP_REGEXP)))
  6352. vty_out (vty, "%ld compiled regexes, using %s of memory%s", count,
  6353. mtype_memstr (memstrbuf, sizeof (memstrbuf),
  6354. count * sizeof (regex_t)),
  6355. VTY_NEWLINE);
  6356. return CMD_SUCCESS;
  6357. }
  6358. /* Show BGP peer's summary information. */
  6359. static int
  6360. bgp_show_summary (struct vty *vty, struct bgp *bgp, int afi, int safi)
  6361. {
  6362. struct peer *peer;
  6363. struct listnode *node, *nnode;
  6364. unsigned int count = 0;
  6365. char timebuf[BGP_UPTIME_LEN];
  6366. int len;
  6367. /* Header string for each address family. */
  6368. static char header[] = "Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd";
  6369. for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
  6370. {
  6371. if (peer->afc[afi][safi])
  6372. {
  6373. if (!count)
  6374. {
  6375. unsigned long ents;
  6376. char memstrbuf[MTYPE_MEMSTR_LEN];
  6377. /* Usage summary and header */
  6378. vty_out (vty,
  6379. "BGP router identifier %s, local AS number %u%s",
  6380. inet_ntoa (bgp->router_id), bgp->as, VTY_NEWLINE);
  6381. ents = bgp_table_count (bgp->rib[afi][safi]);
  6382. vty_out (vty, "RIB entries %ld, using %s of memory%s", ents,
  6383. mtype_memstr (memstrbuf, sizeof (memstrbuf),
  6384. ents * sizeof (struct bgp_node)),
  6385. VTY_NEWLINE);
  6386. /* Peer related usage */
  6387. ents = listcount (bgp->peer);
  6388. vty_out (vty, "Peers %ld, using %s of memory%s",
  6389. ents,
  6390. mtype_memstr (memstrbuf, sizeof (memstrbuf),
  6391. ents * sizeof (struct peer)),
  6392. VTY_NEWLINE);
  6393. if ((ents = listcount (bgp->rsclient)))
  6394. vty_out (vty, "RS-Client peers %ld, using %s of memory%s",
  6395. ents,
  6396. mtype_memstr (memstrbuf, sizeof (memstrbuf),
  6397. ents * sizeof (struct peer)),
  6398. VTY_NEWLINE);
  6399. if ((ents = listcount (bgp->group)))
  6400. vty_out (vty, "Peer groups %ld, using %s of memory%s", ents,
  6401. mtype_memstr (memstrbuf, sizeof (memstrbuf),
  6402. ents * sizeof (struct peer_group)),
  6403. VTY_NEWLINE);
  6404. if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING))
  6405. vty_out (vty, "Dampening enabled.%s", VTY_NEWLINE);
  6406. vty_out (vty, "%s", VTY_NEWLINE);
  6407. vty_out (vty, "%s%s", header, VTY_NEWLINE);
  6408. }
  6409. count++;
  6410. len = vty_out (vty, "%s", peer->host);
  6411. len = 16 - len;
  6412. if (len < 1)
  6413. vty_out (vty, "%s%*s", VTY_NEWLINE, 16, " ");
  6414. else
  6415. vty_out (vty, "%*s", len, " ");
  6416. vty_out (vty, "4 ");
  6417. vty_out (vty, "%5u %7d %7d %8d %4d %4lu ",
  6418. peer->as,
  6419. peer->open_in + peer->update_in + peer->keepalive_in
  6420. + peer->notify_in + peer->refresh_in + peer->dynamic_cap_in,
  6421. peer->open_out + peer->update_out + peer->keepalive_out
  6422. + peer->notify_out + peer->refresh_out
  6423. + peer->dynamic_cap_out,
  6424. 0, 0, (unsigned long) peer->obuf->count);
  6425. vty_out (vty, "%8s",
  6426. peer_uptime (peer->uptime, timebuf, BGP_UPTIME_LEN));
  6427. if (peer->status == Established)
  6428. {
  6429. vty_out (vty, " %8ld", peer->pcount[afi][safi]);
  6430. }
  6431. else
  6432. {
  6433. if (CHECK_FLAG (peer->flags, PEER_FLAG_SHUTDOWN))
  6434. vty_out (vty, " Idle (Admin)");
  6435. else if (CHECK_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW))
  6436. vty_out (vty, " Idle (PfxCt)");
  6437. else
  6438. vty_out (vty, " %-11s", LOOKUP(bgp_status_msg, peer->status));
  6439. }
  6440. vty_out (vty, "%s", VTY_NEWLINE);
  6441. }
  6442. }
  6443. if (count)
  6444. vty_out (vty, "%sTotal number of neighbors %d%s", VTY_NEWLINE,
  6445. count, VTY_NEWLINE);
  6446. else
  6447. vty_out (vty, "No %s neighbor is configured%s",
  6448. afi == AFI_IP ? "IPv4" : "IPv6", VTY_NEWLINE);
  6449. return CMD_SUCCESS;
  6450. }
  6451. static int
  6452. bgp_show_summary_vty (struct vty *vty, const char *name,
  6453. afi_t afi, safi_t safi)
  6454. {
  6455. struct bgp *bgp;
  6456. if (name)
  6457. {
  6458. bgp = bgp_lookup_by_name (name);
  6459. if (! bgp)
  6460. {
  6461. vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE);
  6462. return CMD_WARNING;
  6463. }
  6464. bgp_show_summary (vty, bgp, afi, safi);
  6465. return CMD_SUCCESS;
  6466. }
  6467. bgp = bgp_get_default ();
  6468. if (bgp)
  6469. bgp_show_summary (vty, bgp, afi, safi);
  6470. return CMD_SUCCESS;
  6471. }
  6472. /* `show ip bgp summary' commands. */
  6473. DEFUN (show_ip_bgp_summary,
  6474. show_ip_bgp_summary_cmd,
  6475. "show ip bgp summary",
  6476. SHOW_STR
  6477. IP_STR
  6478. BGP_STR
  6479. "Summary of BGP neighbor status\n")
  6480. {
  6481. return bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_UNICAST);
  6482. }
  6483. DEFUN (show_ip_bgp_instance_summary,
  6484. show_ip_bgp_instance_summary_cmd,
  6485. "show ip bgp view WORD summary",
  6486. SHOW_STR
  6487. IP_STR
  6488. BGP_STR
  6489. "BGP view\n"
  6490. "View name\n"
  6491. "Summary of BGP neighbor status\n")
  6492. {
  6493. return bgp_show_summary_vty (vty, argv[0], AFI_IP, SAFI_UNICAST);
  6494. }
  6495. DEFUN (show_ip_bgp_ipv4_summary,
  6496. show_ip_bgp_ipv4_summary_cmd,
  6497. "show ip bgp ipv4 (unicast|multicast) summary",
  6498. SHOW_STR
  6499. IP_STR
  6500. BGP_STR
  6501. "Address family\n"
  6502. "Address Family modifier\n"
  6503. "Address Family modifier\n"
  6504. "Summary of BGP neighbor status\n")
  6505. {
  6506. if (strncmp (argv[0], "m", 1) == 0)
  6507. return bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_MULTICAST);
  6508. return bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_UNICAST);
  6509. }
  6510. ALIAS (show_ip_bgp_ipv4_summary,
  6511. show_bgp_ipv4_safi_summary_cmd,
  6512. "show bgp ipv4 (unicast|multicast) summary",
  6513. SHOW_STR
  6514. BGP_STR
  6515. "Address family\n"
  6516. "Address Family modifier\n"
  6517. "Address Family modifier\n"
  6518. "Summary of BGP neighbor status\n")
  6519. DEFUN (show_ip_bgp_instance_ipv4_summary,
  6520. show_ip_bgp_instance_ipv4_summary_cmd,
  6521. "show ip bgp view WORD ipv4 (unicast|multicast) summary",
  6522. SHOW_STR
  6523. IP_STR
  6524. BGP_STR
  6525. "BGP view\n"
  6526. "View name\n"
  6527. "Address family\n"
  6528. "Address Family modifier\n"
  6529. "Address Family modifier\n"
  6530. "Summary of BGP neighbor status\n")
  6531. {
  6532. if (strncmp (argv[1], "m", 1) == 0)
  6533. return bgp_show_summary_vty (vty, argv[0], AFI_IP, SAFI_MULTICAST);
  6534. else
  6535. return bgp_show_summary_vty (vty, argv[0], AFI_IP, SAFI_UNICAST);
  6536. }
  6537. ALIAS (show_ip_bgp_instance_ipv4_summary,
  6538. show_bgp_instance_ipv4_safi_summary_cmd,
  6539. "show bgp view WORD ipv4 (unicast|multicast) summary",
  6540. SHOW_STR
  6541. BGP_STR
  6542. "BGP view\n"
  6543. "View name\n"
  6544. "Address family\n"
  6545. "Address Family modifier\n"
  6546. "Address Family modifier\n"
  6547. "Summary of BGP neighbor status\n")
  6548. DEFUN (show_ip_bgp_vpnv4_all_summary,
  6549. show_ip_bgp_vpnv4_all_summary_cmd,
  6550. "show ip bgp vpnv4 all summary",
  6551. SHOW_STR
  6552. IP_STR
  6553. BGP_STR
  6554. "Display VPNv4 NLRI specific information\n"
  6555. "Display information about all VPNv4 NLRIs\n"
  6556. "Summary of BGP neighbor status\n")
  6557. {
  6558. return bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN);
  6559. }
  6560. DEFUN (show_ip_bgp_vpnv4_rd_summary,
  6561. show_ip_bgp_vpnv4_rd_summary_cmd,
  6562. "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn summary",
  6563. SHOW_STR
  6564. IP_STR
  6565. BGP_STR
  6566. "Display VPNv4 NLRI specific information\n"
  6567. "Display information for a route distinguisher\n"
  6568. "VPN Route Distinguisher\n"
  6569. "Summary of BGP neighbor status\n")
  6570. {
  6571. int ret;
  6572. struct prefix_rd prd;
  6573. ret = str2prefix_rd (argv[0], &prd);
  6574. if (! ret)
  6575. {
  6576. vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
  6577. return CMD_WARNING;
  6578. }
  6579. return bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN);
  6580. }
  6581. #ifdef HAVE_IPV6
  6582. DEFUN (show_bgp_summary,
  6583. show_bgp_summary_cmd,
  6584. "show bgp summary",
  6585. SHOW_STR
  6586. BGP_STR
  6587. "Summary of BGP neighbor status\n")
  6588. {
  6589. return bgp_show_summary_vty (vty, NULL, AFI_IP6, SAFI_UNICAST);
  6590. }
  6591. DEFUN (show_bgp_instance_summary,
  6592. show_bgp_instance_summary_cmd,
  6593. "show bgp view WORD summary",
  6594. SHOW_STR
  6595. BGP_STR
  6596. "BGP view\n"
  6597. "View name\n"
  6598. "Summary of BGP neighbor status\n")
  6599. {
  6600. return bgp_show_summary_vty (vty, argv[0], AFI_IP6, SAFI_UNICAST);
  6601. }
  6602. ALIAS (show_bgp_summary,
  6603. show_bgp_ipv6_summary_cmd,
  6604. "show bgp ipv6 summary",
  6605. SHOW_STR
  6606. BGP_STR
  6607. "Address family\n"
  6608. "Summary of BGP neighbor status\n")
  6609. ALIAS (show_bgp_instance_summary,
  6610. show_bgp_instance_ipv6_summary_cmd,
  6611. "show bgp view WORD ipv6 summary",
  6612. SHOW_STR
  6613. BGP_STR
  6614. "BGP view\n"
  6615. "View name\n"
  6616. "Address family\n"
  6617. "Summary of BGP neighbor status\n")
  6618. DEFUN (show_bgp_ipv6_safi_summary,
  6619. show_bgp_ipv6_safi_summary_cmd,
  6620. "show bgp ipv6 (unicast|multicast) summary",
  6621. SHOW_STR
  6622. BGP_STR
  6623. "Address family\n"
  6624. "Address Family modifier\n"
  6625. "Address Family modifier\n"
  6626. "Summary of BGP neighbor status\n")
  6627. {
  6628. if (strncmp (argv[0], "m", 1) == 0)
  6629. return bgp_show_summary_vty (vty, NULL, AFI_IP6, SAFI_MULTICAST);
  6630. return bgp_show_summary_vty (vty, NULL, AFI_IP6, SAFI_UNICAST);
  6631. }
  6632. DEFUN (show_bgp_instance_ipv6_safi_summary,
  6633. show_bgp_instance_ipv6_safi_summary_cmd,
  6634. "show bgp view WORD ipv6 (unicast|multicast) summary",
  6635. SHOW_STR
  6636. BGP_STR
  6637. "BGP view\n"
  6638. "View name\n"
  6639. "Address family\n"
  6640. "Address Family modifier\n"
  6641. "Address Family modifier\n"
  6642. "Summary of BGP neighbor status\n")
  6643. {
  6644. if (strncmp (argv[1], "m", 1) == 0)
  6645. return bgp_show_summary_vty (vty, argv[0], AFI_IP6, SAFI_MULTICAST);
  6646. return bgp_show_summary_vty (vty, argv[0], AFI_IP6, SAFI_UNICAST);
  6647. }
  6648. /* old command */
  6649. DEFUN (show_ipv6_bgp_summary,
  6650. show_ipv6_bgp_summary_cmd,
  6651. "show ipv6 bgp summary",
  6652. SHOW_STR
  6653. IPV6_STR
  6654. BGP_STR
  6655. "Summary of BGP neighbor status\n")
  6656. {
  6657. return bgp_show_summary_vty (vty, NULL, AFI_IP6, SAFI_UNICAST);
  6658. }
  6659. /* old command */
  6660. DEFUN (show_ipv6_mbgp_summary,
  6661. show_ipv6_mbgp_summary_cmd,
  6662. "show ipv6 mbgp summary",
  6663. SHOW_STR
  6664. IPV6_STR
  6665. MBGP_STR
  6666. "Summary of BGP neighbor status\n")
  6667. {
  6668. return bgp_show_summary_vty (vty, NULL, AFI_IP6, SAFI_MULTICAST);
  6669. }
  6670. #endif /* HAVE_IPV6 */
  6671. const char *
  6672. afi_safi_print (afi_t afi, safi_t safi)
  6673. {
  6674. if (afi == AFI_IP && safi == SAFI_UNICAST)
  6675. return "IPv4 Unicast";
  6676. else if (afi == AFI_IP && safi == SAFI_MULTICAST)
  6677. return "IPv4 Multicast";
  6678. else if (afi == AFI_IP && safi == SAFI_MPLS_VPN)
  6679. return "VPN-IPv4 Unicast";
  6680. else if (afi == AFI_IP && safi == SAFI_ENCAP)
  6681. return "ENCAP-IPv4 Unicast";
  6682. else if (afi == AFI_IP6 && safi == SAFI_UNICAST)
  6683. return "IPv6 Unicast";
  6684. else if (afi == AFI_IP6 && safi == SAFI_MULTICAST)
  6685. return "IPv6 Multicast";
  6686. else if (afi == AFI_IP6 && safi == SAFI_MPLS_VPN)
  6687. return "VPN-IPv6 Unicast";
  6688. else if (afi == AFI_IP6 && safi == SAFI_ENCAP)
  6689. return "ENCAP-IPv6 Unicast";
  6690. else
  6691. return "Unknown";
  6692. }
  6693. /* Show BGP peer's information. */
  6694. enum show_type
  6695. {
  6696. show_all,
  6697. show_peer
  6698. };
  6699. static void
  6700. bgp_show_peer_afi_orf_cap (struct vty *vty, struct peer *p,
  6701. afi_t afi, safi_t safi,
  6702. u_int16_t adv_smcap, u_int16_t adv_rmcap,
  6703. u_int16_t rcv_smcap, u_int16_t rcv_rmcap)
  6704. {
  6705. /* Send-Mode */
  6706. if (CHECK_FLAG (p->af_cap[afi][safi], adv_smcap)
  6707. || CHECK_FLAG (p->af_cap[afi][safi], rcv_smcap))
  6708. {
  6709. vty_out (vty, " Send-mode: ");
  6710. if (CHECK_FLAG (p->af_cap[afi][safi], adv_smcap))
  6711. vty_out (vty, "advertised");
  6712. if (CHECK_FLAG (p->af_cap[afi][safi], rcv_smcap))
  6713. vty_out (vty, "%sreceived",
  6714. CHECK_FLAG (p->af_cap[afi][safi], adv_smcap) ?
  6715. ", " : "");
  6716. vty_out (vty, "%s", VTY_NEWLINE);
  6717. }
  6718. /* Receive-Mode */
  6719. if (CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap)
  6720. || CHECK_FLAG (p->af_cap[afi][safi], rcv_rmcap))
  6721. {
  6722. vty_out (vty, " Receive-mode: ");
  6723. if (CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap))
  6724. vty_out (vty, "advertised");
  6725. if (CHECK_FLAG (p->af_cap[afi][safi], rcv_rmcap))
  6726. vty_out (vty, "%sreceived",
  6727. CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap) ?
  6728. ", " : "");
  6729. vty_out (vty, "%s", VTY_NEWLINE);
  6730. }
  6731. }
  6732. static void
  6733. bgp_show_peer_afi (struct vty *vty, struct peer *p, afi_t afi, safi_t safi)
  6734. {
  6735. struct bgp_filter *filter;
  6736. char orf_pfx_name[BUFSIZ];
  6737. int orf_pfx_count;
  6738. filter = &p->filter[afi][safi];
  6739. vty_out (vty, " For address family: %s%s", afi_safi_print (afi, safi),
  6740. VTY_NEWLINE);
  6741. if (p->af_group[afi][safi])
  6742. vty_out (vty, " %s peer-group member%s", p->group->name, VTY_NEWLINE);
  6743. if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV)
  6744. || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV)
  6745. || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV)
  6746. || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV)
  6747. || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_RCV)
  6748. || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_OLD_RCV))
  6749. vty_out (vty, " AF-dependant capabilities:%s", VTY_NEWLINE);
  6750. if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV)
  6751. || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV)
  6752. || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV)
  6753. || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_RCV))
  6754. {
  6755. vty_out (vty, " Outbound Route Filter (ORF) type (%d) Prefix-list:%s",
  6756. ORF_TYPE_PREFIX, VTY_NEWLINE);
  6757. bgp_show_peer_afi_orf_cap (vty, p, afi, safi,
  6758. PEER_CAP_ORF_PREFIX_SM_ADV,
  6759. PEER_CAP_ORF_PREFIX_RM_ADV,
  6760. PEER_CAP_ORF_PREFIX_SM_RCV,
  6761. PEER_CAP_ORF_PREFIX_RM_RCV);
  6762. }
  6763. if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV)
  6764. || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV)
  6765. || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV)
  6766. || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_OLD_RCV))
  6767. {
  6768. vty_out (vty, " Outbound Route Filter (ORF) type (%d) Prefix-list:%s",
  6769. ORF_TYPE_PREFIX_OLD, VTY_NEWLINE);
  6770. bgp_show_peer_afi_orf_cap (vty, p, afi, safi,
  6771. PEER_CAP_ORF_PREFIX_SM_ADV,
  6772. PEER_CAP_ORF_PREFIX_RM_ADV,
  6773. PEER_CAP_ORF_PREFIX_SM_OLD_RCV,
  6774. PEER_CAP_ORF_PREFIX_RM_OLD_RCV);
  6775. }
  6776. sprintf (orf_pfx_name, "%s.%d.%d", p->host, afi, safi);
  6777. orf_pfx_count = prefix_bgp_show_prefix_list (NULL, afi, orf_pfx_name);
  6778. if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_PREFIX_SEND)
  6779. || orf_pfx_count)
  6780. {
  6781. vty_out (vty, " Outbound Route Filter (ORF):");
  6782. if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_PREFIX_SEND))
  6783. vty_out (vty, " sent;");
  6784. if (orf_pfx_count)
  6785. vty_out (vty, " received (%d entries)", orf_pfx_count);
  6786. vty_out (vty, "%s", VTY_NEWLINE);
  6787. }
  6788. if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_WAIT_REFRESH))
  6789. vty_out (vty, " First update is deferred until ORF or ROUTE-REFRESH is received%s", VTY_NEWLINE);
  6790. if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT))
  6791. vty_out (vty, " Route-Reflector Client%s", VTY_NEWLINE);
  6792. if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
  6793. vty_out (vty, " Route-Server Client%s", VTY_NEWLINE);
  6794. if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG))
  6795. vty_out (vty, " Inbound soft reconfiguration allowed%s", VTY_NEWLINE);
  6796. if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS))
  6797. vty_out (vty, " Private AS number removed from updates to this neighbor%s", VTY_NEWLINE);
  6798. if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF))
  6799. vty_out (vty, " NEXT_HOP is always this router%s", VTY_NEWLINE);
  6800. if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_AS_PATH_UNCHANGED))
  6801. vty_out (vty, " AS_PATH is propagated unchanged to this neighbor%s", VTY_NEWLINE);
  6802. if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_UNCHANGED))
  6803. vty_out (vty, " NEXT_HOP is propagated unchanged to this neighbor%s", VTY_NEWLINE);
  6804. if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED))
  6805. vty_out (vty, " MED is propagated unchanged to this neighbor%s", VTY_NEWLINE);
  6806. if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY)
  6807. || CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY))
  6808. {
  6809. vty_out (vty, " Community attribute sent to this neighbor");
  6810. if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY)
  6811. && CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY))
  6812. vty_out (vty, "(both)%s", VTY_NEWLINE);
  6813. else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY))
  6814. vty_out (vty, "(extended)%s", VTY_NEWLINE);
  6815. else
  6816. vty_out (vty, "(standard)%s", VTY_NEWLINE);
  6817. }
  6818. if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE))
  6819. {
  6820. vty_out (vty, " Default information originate,");
  6821. if (p->default_rmap[afi][safi].name)
  6822. vty_out (vty, " default route-map %s%s,",
  6823. p->default_rmap[afi][safi].map ? "*" : "",
  6824. p->default_rmap[afi][safi].name);
  6825. if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE))
  6826. vty_out (vty, " default sent%s", VTY_NEWLINE);
  6827. else
  6828. vty_out (vty, " default not sent%s", VTY_NEWLINE);
  6829. }
  6830. if (filter->plist[FILTER_IN].name
  6831. || filter->dlist[FILTER_IN].name
  6832. || filter->aslist[FILTER_IN].name
  6833. || filter->map[RMAP_IN].name)
  6834. vty_out (vty, " Inbound path policy configured%s", VTY_NEWLINE);
  6835. if (filter->plist[FILTER_OUT].name
  6836. || filter->dlist[FILTER_OUT].name
  6837. || filter->aslist[FILTER_OUT].name
  6838. || filter->map[RMAP_OUT].name
  6839. || filter->usmap.name)
  6840. vty_out (vty, " Outbound path policy configured%s", VTY_NEWLINE);
  6841. if (filter->map[RMAP_IMPORT].name)
  6842. vty_out (vty, " Import policy for this RS-client configured%s", VTY_NEWLINE);
  6843. if (filter->map[RMAP_EXPORT].name)
  6844. vty_out (vty, " Export policy for this RS-client configured%s", VTY_NEWLINE);
  6845. /* prefix-list */
  6846. if (filter->plist[FILTER_IN].name)
  6847. vty_out (vty, " Incoming update prefix filter list is %s%s%s",
  6848. filter->plist[FILTER_IN].plist ? "*" : "",
  6849. filter->plist[FILTER_IN].name,
  6850. VTY_NEWLINE);
  6851. if (filter->plist[FILTER_OUT].name)
  6852. vty_out (vty, " Outgoing update prefix filter list is %s%s%s",
  6853. filter->plist[FILTER_OUT].plist ? "*" : "",
  6854. filter->plist[FILTER_OUT].name,
  6855. VTY_NEWLINE);
  6856. /* distribute-list */
  6857. if (filter->dlist[FILTER_IN].name)
  6858. vty_out (vty, " Incoming update network filter list is %s%s%s",
  6859. filter->dlist[FILTER_IN].alist ? "*" : "",
  6860. filter->dlist[FILTER_IN].name,
  6861. VTY_NEWLINE);
  6862. if (filter->dlist[FILTER_OUT].name)
  6863. vty_out (vty, " Outgoing update network filter list is %s%s%s",
  6864. filter->dlist[FILTER_OUT].alist ? "*" : "",
  6865. filter->dlist[FILTER_OUT].name,
  6866. VTY_NEWLINE);
  6867. /* filter-list. */
  6868. if (filter->aslist[FILTER_IN].name)
  6869. vty_out (vty, " Incoming update AS path filter list is %s%s%s",
  6870. filter->aslist[FILTER_IN].aslist ? "*" : "",
  6871. filter->aslist[FILTER_IN].name,
  6872. VTY_NEWLINE);
  6873. if (filter->aslist[FILTER_OUT].name)
  6874. vty_out (vty, " Outgoing update AS path filter list is %s%s%s",
  6875. filter->aslist[FILTER_OUT].aslist ? "*" : "",
  6876. filter->aslist[FILTER_OUT].name,
  6877. VTY_NEWLINE);
  6878. /* route-map. */
  6879. if (filter->map[RMAP_IN].name)
  6880. vty_out (vty, " Route map for incoming advertisements is %s%s%s",
  6881. filter->map[RMAP_IN].map ? "*" : "",
  6882. filter->map[RMAP_IN].name,
  6883. VTY_NEWLINE);
  6884. if (filter->map[RMAP_OUT].name)
  6885. vty_out (vty, " Route map for outgoing advertisements is %s%s%s",
  6886. filter->map[RMAP_OUT].map ? "*" : "",
  6887. filter->map[RMAP_OUT].name,
  6888. VTY_NEWLINE);
  6889. if (filter->map[RMAP_IMPORT].name)
  6890. vty_out (vty, " Route map for advertisements going into this RS-client's table is %s%s%s",
  6891. filter->map[RMAP_IMPORT].map ? "*" : "",
  6892. filter->map[RMAP_IMPORT].name,
  6893. VTY_NEWLINE);
  6894. if (filter->map[RMAP_EXPORT].name)
  6895. vty_out (vty, " Route map for advertisements coming from this RS-client is %s%s%s",
  6896. filter->map[RMAP_EXPORT].map ? "*" : "",
  6897. filter->map[RMAP_EXPORT].name,
  6898. VTY_NEWLINE);
  6899. /* unsuppress-map */
  6900. if (filter->usmap.name)
  6901. vty_out (vty, " Route map for selective unsuppress is %s%s%s",
  6902. filter->usmap.map ? "*" : "",
  6903. filter->usmap.name, VTY_NEWLINE);
  6904. /* Receive prefix count */
  6905. vty_out (vty, " %ld accepted prefixes%s", p->pcount[afi][safi], VTY_NEWLINE);
  6906. /* Maximum prefix */
  6907. if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX))
  6908. {
  6909. vty_out (vty, " Maximum prefixes allowed %ld%s%s", p->pmax[afi][safi],
  6910. CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING)
  6911. ? " (warning-only)" : "", VTY_NEWLINE);
  6912. vty_out (vty, " Threshold for warning message %d%%",
  6913. p->pmax_threshold[afi][safi]);
  6914. if (p->pmax_restart[afi][safi])
  6915. vty_out (vty, ", restart interval %d min", p->pmax_restart[afi][safi]);
  6916. vty_out (vty, "%s", VTY_NEWLINE);
  6917. }
  6918. vty_out (vty, "%s", VTY_NEWLINE);
  6919. }
  6920. static void
  6921. bgp_show_peer (struct vty *vty, struct peer *p)
  6922. {
  6923. struct bgp *bgp;
  6924. char buf1[BUFSIZ];
  6925. char timebuf[BGP_UPTIME_LEN];
  6926. afi_t afi;
  6927. safi_t safi;
  6928. bgp = p->bgp;
  6929. /* Configured IP address. */
  6930. vty_out (vty, "BGP neighbor is %s, ", p->host);
  6931. vty_out (vty, "remote AS %u, ", p->as);
  6932. vty_out (vty, "local AS %u%s%s, ",
  6933. p->change_local_as ? p->change_local_as : p->local_as,
  6934. CHECK_FLAG (p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND) ?
  6935. " no-prepend" : "",
  6936. CHECK_FLAG (p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS) ?
  6937. " replace-as" : "");
  6938. vty_out (vty, "%s link%s",
  6939. p->as == p->local_as ? "internal" : "external",
  6940. VTY_NEWLINE);
  6941. /* Description. */
  6942. if (p->desc)
  6943. vty_out (vty, " Description: %s%s", p->desc, VTY_NEWLINE);
  6944. /* Peer-group */
  6945. if (p->group)
  6946. vty_out (vty, " Member of peer-group %s for session parameters%s",
  6947. p->group->name, VTY_NEWLINE);
  6948. /* Administrative shutdown. */
  6949. if (CHECK_FLAG (p->flags, PEER_FLAG_SHUTDOWN))
  6950. vty_out (vty, " Administratively shut down%s", VTY_NEWLINE);
  6951. /* BGP Version. */
  6952. vty_out (vty, " BGP version 4");
  6953. vty_out (vty, ", remote router ID %s%s",
  6954. inet_ntop (AF_INET, &p->remote_id, buf1, BUFSIZ),
  6955. VTY_NEWLINE);
  6956. /* Confederation */
  6957. if (CHECK_FLAG (bgp->config, BGP_CONFIG_CONFEDERATION)
  6958. && bgp_confederation_peers_check (bgp, p->as))
  6959. vty_out (vty, " Neighbor under common administration%s", VTY_NEWLINE);
  6960. /* Status. */
  6961. vty_out (vty, " BGP state = %s",
  6962. LOOKUP (bgp_status_msg, p->status));
  6963. if (p->status == Established)
  6964. vty_out (vty, ", up for %8s",
  6965. peer_uptime (p->uptime, timebuf, BGP_UPTIME_LEN));
  6966. else if (p->status == Active)
  6967. {
  6968. if (CHECK_FLAG (p->flags, PEER_FLAG_PASSIVE))
  6969. vty_out (vty, " (passive)");
  6970. else if (CHECK_FLAG (p->sflags, PEER_STATUS_NSF_WAIT))
  6971. vty_out (vty, " (NSF passive)");
  6972. }
  6973. vty_out (vty, "%s", VTY_NEWLINE);
  6974. /* read timer */
  6975. vty_out (vty, " Last read %s", peer_uptime (p->readtime, timebuf, BGP_UPTIME_LEN));
  6976. /* Configured timer values. */
  6977. vty_out (vty, ", hold time is %d, keepalive interval is %d seconds%s",
  6978. p->v_holdtime, p->v_keepalive, VTY_NEWLINE);
  6979. if (CHECK_FLAG (p->config, PEER_CONFIG_TIMER))
  6980. {
  6981. vty_out (vty, " Configured hold time is %d", p->holdtime);
  6982. vty_out (vty, ", keepalive interval is %d seconds%s",
  6983. p->keepalive, VTY_NEWLINE);
  6984. }
  6985. /* Capability. */
  6986. if (p->status == Established)
  6987. {
  6988. if (p->cap
  6989. || p->afc_adv[AFI_IP][SAFI_UNICAST]
  6990. || p->afc_recv[AFI_IP][SAFI_UNICAST]
  6991. || p->afc_adv[AFI_IP][SAFI_MULTICAST]
  6992. || p->afc_recv[AFI_IP][SAFI_MULTICAST]
  6993. #ifdef HAVE_IPV6
  6994. || p->afc_adv[AFI_IP6][SAFI_UNICAST]
  6995. || p->afc_recv[AFI_IP6][SAFI_UNICAST]
  6996. || p->afc_adv[AFI_IP6][SAFI_MULTICAST]
  6997. || p->afc_recv[AFI_IP6][SAFI_MULTICAST]
  6998. || p->afc_adv[AFI_IP6][SAFI_MPLS_VPN]
  6999. || p->afc_recv[AFI_IP6][SAFI_MPLS_VPN]
  7000. || p->afc_adv[AFI_IP6][SAFI_ENCAP]
  7001. || p->afc_recv[AFI_IP6][SAFI_ENCAP]
  7002. #endif /* HAVE_IPV6 */
  7003. || p->afc_adv[AFI_IP][SAFI_ENCAP]
  7004. || p->afc_recv[AFI_IP][SAFI_ENCAP]
  7005. || p->afc_adv[AFI_IP][SAFI_MPLS_VPN]
  7006. || p->afc_recv[AFI_IP][SAFI_MPLS_VPN])
  7007. {
  7008. vty_out (vty, " Neighbor capabilities:%s", VTY_NEWLINE);
  7009. /* AS4 */
  7010. if (CHECK_FLAG (p->cap, PEER_CAP_AS4_RCV)
  7011. || CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV))
  7012. {
  7013. vty_out (vty, " 4 Byte AS:");
  7014. if (CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV))
  7015. vty_out (vty, " advertised");
  7016. if (CHECK_FLAG (p->cap, PEER_CAP_AS4_RCV))
  7017. vty_out (vty, " %sreceived",
  7018. CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV) ? "and " : "");
  7019. vty_out (vty, "%s", VTY_NEWLINE);
  7020. }
  7021. /* Dynamic */
  7022. if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_RCV)
  7023. || CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV))
  7024. {
  7025. vty_out (vty, " Dynamic:");
  7026. if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV))
  7027. vty_out (vty, " advertised");
  7028. if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_RCV))
  7029. vty_out (vty, " %sreceived",
  7030. CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV) ? "and " : "");
  7031. vty_out (vty, "%s", VTY_NEWLINE);
  7032. }
  7033. /* Route Refresh */
  7034. if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV)
  7035. || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV)
  7036. || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV))
  7037. {
  7038. vty_out (vty, " Route refresh:");
  7039. if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV))
  7040. vty_out (vty, " advertised");
  7041. if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV)
  7042. || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV))
  7043. vty_out (vty, " %sreceived(%s)",
  7044. CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV) ? "and " : "",
  7045. (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV)
  7046. && CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV)) ?
  7047. "old & new" : CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV) ? "old" : "new");
  7048. vty_out (vty, "%s", VTY_NEWLINE);
  7049. }
  7050. /* Multiprotocol Extensions */
  7051. for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
  7052. for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
  7053. if (p->afc_adv[afi][safi] || p->afc_recv[afi][safi])
  7054. {
  7055. vty_out (vty, " Address family %s:", afi_safi_print (afi, safi));
  7056. if (p->afc_adv[afi][safi])
  7057. vty_out (vty, " advertised");
  7058. if (p->afc_recv[afi][safi])
  7059. vty_out (vty, " %sreceived", p->afc_adv[afi][safi] ? "and " : "");
  7060. vty_out (vty, "%s", VTY_NEWLINE);
  7061. }
  7062. /* Gracefull Restart */
  7063. if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV)
  7064. || CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV))
  7065. {
  7066. vty_out (vty, " Graceful Restart Capabilty:");
  7067. if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV))
  7068. vty_out (vty, " advertised");
  7069. if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV))
  7070. vty_out (vty, " %sreceived",
  7071. CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV) ? "and " : "");
  7072. vty_out (vty, "%s", VTY_NEWLINE);
  7073. if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV))
  7074. {
  7075. int restart_af_count = 0;
  7076. vty_out (vty, " Remote Restart timer is %d seconds%s",
  7077. p->v_gr_restart, VTY_NEWLINE);
  7078. vty_out (vty, " Address families by peer:%s ", VTY_NEWLINE);
  7079. for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
  7080. for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
  7081. if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_RESTART_AF_RCV))
  7082. {
  7083. vty_out (vty, "%s%s(%s)", restart_af_count ? ", " : "",
  7084. afi_safi_print (afi, safi),
  7085. CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_RESTART_AF_PRESERVE_RCV) ?
  7086. "preserved" : "not preserved");
  7087. restart_af_count++;
  7088. }
  7089. if (! restart_af_count)
  7090. vty_out (vty, "none");
  7091. vty_out (vty, "%s", VTY_NEWLINE);
  7092. }
  7093. }
  7094. }
  7095. }
  7096. /* graceful restart information */
  7097. if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV)
  7098. || p->t_gr_restart
  7099. || p->t_gr_stale)
  7100. {
  7101. int eor_send_af_count = 0;
  7102. int eor_receive_af_count = 0;
  7103. vty_out (vty, " Graceful restart informations:%s", VTY_NEWLINE);
  7104. if (p->status == Established)
  7105. {
  7106. vty_out (vty, " End-of-RIB send: ");
  7107. for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
  7108. for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
  7109. if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_EOR_SEND))
  7110. {
  7111. vty_out (vty, "%s%s", eor_send_af_count ? ", " : "",
  7112. afi_safi_print (afi, safi));
  7113. eor_send_af_count++;
  7114. }
  7115. vty_out (vty, "%s", VTY_NEWLINE);
  7116. vty_out (vty, " End-of-RIB received: ");
  7117. for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
  7118. for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
  7119. if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_EOR_RECEIVED))
  7120. {
  7121. vty_out (vty, "%s%s", eor_receive_af_count ? ", " : "",
  7122. afi_safi_print (afi, safi));
  7123. eor_receive_af_count++;
  7124. }
  7125. vty_out (vty, "%s", VTY_NEWLINE);
  7126. }
  7127. if (p->t_gr_restart)
  7128. vty_out (vty, " The remaining time of restart timer is %ld%s",
  7129. thread_timer_remain_second (p->t_gr_restart), VTY_NEWLINE);
  7130. if (p->t_gr_stale)
  7131. vty_out (vty, " The remaining time of stalepath timer is %ld%s",
  7132. thread_timer_remain_second (p->t_gr_stale), VTY_NEWLINE);
  7133. }
  7134. /* Packet counts. */
  7135. vty_out (vty, " Message statistics:%s", VTY_NEWLINE);
  7136. vty_out (vty, " Inq depth is 0%s", VTY_NEWLINE);
  7137. vty_out (vty, " Outq depth is %lu%s", (unsigned long) p->obuf->count, VTY_NEWLINE);
  7138. vty_out (vty, " Sent Rcvd%s", VTY_NEWLINE);
  7139. vty_out (vty, " Opens: %10d %10d%s", p->open_out, p->open_in, VTY_NEWLINE);
  7140. vty_out (vty, " Notifications: %10d %10d%s", p->notify_out, p->notify_in, VTY_NEWLINE);
  7141. vty_out (vty, " Updates: %10d %10d%s", p->update_out, p->update_in, VTY_NEWLINE);
  7142. vty_out (vty, " Keepalives: %10d %10d%s", p->keepalive_out, p->keepalive_in, VTY_NEWLINE);
  7143. vty_out (vty, " Route Refresh: %10d %10d%s", p->refresh_out, p->refresh_in, VTY_NEWLINE);
  7144. vty_out (vty, " Capability: %10d %10d%s", p->dynamic_cap_out, p->dynamic_cap_in, VTY_NEWLINE);
  7145. vty_out (vty, " Total: %10d %10d%s", p->open_out + p->notify_out +
  7146. p->update_out + p->keepalive_out + p->refresh_out + p->dynamic_cap_out,
  7147. p->open_in + p->notify_in + p->update_in + p->keepalive_in + p->refresh_in +
  7148. p->dynamic_cap_in, VTY_NEWLINE);
  7149. /* advertisement-interval */
  7150. vty_out (vty, " Minimum time between advertisement runs is %d seconds%s",
  7151. p->v_routeadv, VTY_NEWLINE);
  7152. /* Update-source. */
  7153. if (p->update_if || p->update_source)
  7154. {
  7155. vty_out (vty, " Update source is ");
  7156. if (p->update_if)
  7157. vty_out (vty, "%s", p->update_if);
  7158. else if (p->update_source)
  7159. vty_out (vty, "%s",
  7160. sockunion2str (p->update_source, buf1, SU_ADDRSTRLEN));
  7161. vty_out (vty, "%s", VTY_NEWLINE);
  7162. }
  7163. /* Default weight */
  7164. if (CHECK_FLAG (p->config, PEER_CONFIG_WEIGHT))
  7165. vty_out (vty, " Default weight %d%s", p->weight,
  7166. VTY_NEWLINE);
  7167. vty_out (vty, "%s", VTY_NEWLINE);
  7168. /* Address Family Information */
  7169. for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
  7170. for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
  7171. if (p->afc[afi][safi])
  7172. bgp_show_peer_afi (vty, p, afi, safi);
  7173. vty_out (vty, " Connections established %d; dropped %d%s",
  7174. p->established, p->dropped,
  7175. VTY_NEWLINE);
  7176. if (! p->dropped)
  7177. vty_out (vty, " Last reset never%s", VTY_NEWLINE);
  7178. else
  7179. vty_out (vty, " Last reset %s, due to %s%s",
  7180. peer_uptime (p->resettime, timebuf, BGP_UPTIME_LEN),
  7181. peer_down_str[(int) p->last_reset], VTY_NEWLINE);
  7182. if (CHECK_FLAG (p->sflags, PEER_STATUS_PREFIX_OVERFLOW))
  7183. {
  7184. vty_out (vty, " Peer had exceeded the max. no. of prefixes configured.%s", VTY_NEWLINE);
  7185. if (p->t_pmax_restart)
  7186. vty_out (vty, " Reduce the no. of prefix from %s, will restart in %ld seconds%s",
  7187. p->host, thread_timer_remain_second (p->t_pmax_restart),
  7188. VTY_NEWLINE);
  7189. else
  7190. vty_out (vty, " Reduce the no. of prefix and clear ip bgp %s to restore peering%s",
  7191. p->host, VTY_NEWLINE);
  7192. }
  7193. /* EBGP Multihop and GTSM */
  7194. if (p->sort != BGP_PEER_IBGP)
  7195. {
  7196. if (p->gtsm_hops > 0)
  7197. vty_out (vty, " External BGP neighbor may be up to %d hops away.%s",
  7198. p->gtsm_hops, VTY_NEWLINE);
  7199. else if (p->ttl > 1)
  7200. vty_out (vty, " External BGP neighbor may be up to %d hops away.%s",
  7201. p->ttl, VTY_NEWLINE);
  7202. }
  7203. else
  7204. {
  7205. if (p->gtsm_hops > 0)
  7206. vty_out (vty, " Internal BGP neighbor may be up to %d hops away.%s",
  7207. p->gtsm_hops, VTY_NEWLINE);
  7208. }
  7209. /* Local address. */
  7210. if (p->su_local)
  7211. {
  7212. vty_out (vty, "Local host: %s, Local port: %d%s",
  7213. sockunion2str (p->su_local, buf1, SU_ADDRSTRLEN),
  7214. ntohs (p->su_local->sin.sin_port),
  7215. VTY_NEWLINE);
  7216. }
  7217. /* Remote address. */
  7218. if (p->su_remote)
  7219. {
  7220. vty_out (vty, "Foreign host: %s, Foreign port: %d%s",
  7221. sockunion2str (p->su_remote, buf1, SU_ADDRSTRLEN),
  7222. ntohs (p->su_remote->sin.sin_port),
  7223. VTY_NEWLINE);
  7224. }
  7225. /* Nexthop display. */
  7226. if (p->su_local)
  7227. {
  7228. vty_out (vty, "Nexthop: %s%s",
  7229. inet_ntop (AF_INET, &p->nexthop.v4, buf1, BUFSIZ),
  7230. VTY_NEWLINE);
  7231. #ifdef HAVE_IPV6
  7232. vty_out (vty, "Nexthop global: %s%s",
  7233. inet_ntop (AF_INET6, &p->nexthop.v6_global, buf1, BUFSIZ),
  7234. VTY_NEWLINE);
  7235. vty_out (vty, "Nexthop local: %s%s",
  7236. inet_ntop (AF_INET6, &p->nexthop.v6_local, buf1, BUFSIZ),
  7237. VTY_NEWLINE);
  7238. vty_out (vty, "BGP connection: %s%s",
  7239. p->shared_network ? "shared network" : "non shared network",
  7240. VTY_NEWLINE);
  7241. #endif /* HAVE_IPV6 */
  7242. }
  7243. /* TCP metrics. */
  7244. if (p->status == Established && p->rtt)
  7245. vty_out (vty, "Estimated round trip time: %d ms%s",
  7246. p->rtt, VTY_NEWLINE);
  7247. /* Timer information. */
  7248. if (p->t_start)
  7249. vty_out (vty, "Next start timer due in %ld seconds%s",
  7250. thread_timer_remain_second (p->t_start), VTY_NEWLINE);
  7251. if (p->t_connect)
  7252. vty_out (vty, "Next connect timer due in %ld seconds%s",
  7253. thread_timer_remain_second (p->t_connect), VTY_NEWLINE);
  7254. vty_out (vty, "Read thread: %s Write thread: %s%s",
  7255. p->t_read ? "on" : "off",
  7256. p->t_write ? "on" : "off",
  7257. VTY_NEWLINE);
  7258. if (p->notify.code == BGP_NOTIFY_OPEN_ERR
  7259. && p->notify.subcode == BGP_NOTIFY_OPEN_UNSUP_CAPBL)
  7260. bgp_capability_vty_out (vty, p);
  7261. vty_out (vty, "%s", VTY_NEWLINE);
  7262. }
  7263. static int
  7264. bgp_show_neighbor (struct vty *vty, struct bgp *bgp,
  7265. enum show_type type, union sockunion *su)
  7266. {
  7267. struct listnode *node, *nnode;
  7268. struct peer *peer;
  7269. int find = 0;
  7270. for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
  7271. {
  7272. switch (type)
  7273. {
  7274. case show_all:
  7275. bgp_show_peer (vty, peer);
  7276. break;
  7277. case show_peer:
  7278. if (sockunion_same (&peer->su, su))
  7279. {
  7280. find = 1;
  7281. bgp_show_peer (vty, peer);
  7282. }
  7283. break;
  7284. }
  7285. }
  7286. if (type == show_peer && ! find)
  7287. vty_out (vty, "%% No such neighbor%s", VTY_NEWLINE);
  7288. return CMD_SUCCESS;
  7289. }
  7290. static int
  7291. bgp_show_neighbor_vty (struct vty *vty, const char *name,
  7292. enum show_type type, const char *ip_str)
  7293. {
  7294. int ret;
  7295. struct bgp *bgp;
  7296. union sockunion su;
  7297. if (ip_str)
  7298. {
  7299. ret = str2sockunion (ip_str, &su);
  7300. if (ret < 0)
  7301. {
  7302. vty_out (vty, "%% Malformed address: %s%s", ip_str, VTY_NEWLINE);
  7303. return CMD_WARNING;
  7304. }
  7305. }
  7306. if (name)
  7307. {
  7308. bgp = bgp_lookup_by_name (name);
  7309. if (! bgp)
  7310. {
  7311. vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE);
  7312. return CMD_WARNING;
  7313. }
  7314. bgp_show_neighbor (vty, bgp, type, &su);
  7315. return CMD_SUCCESS;
  7316. }
  7317. bgp = bgp_get_default ();
  7318. if (bgp)
  7319. bgp_show_neighbor (vty, bgp, type, &su);
  7320. return CMD_SUCCESS;
  7321. }
  7322. /* "show ip bgp neighbors" commands. */
  7323. DEFUN (show_ip_bgp_neighbors,
  7324. show_ip_bgp_neighbors_cmd,
  7325. "show ip bgp neighbors",
  7326. SHOW_STR
  7327. IP_STR
  7328. BGP_STR
  7329. "Detailed information on TCP and BGP neighbor connections\n")
  7330. {
  7331. return bgp_show_neighbor_vty (vty, NULL, show_all, NULL);
  7332. }
  7333. ALIAS (show_ip_bgp_neighbors,
  7334. show_ip_bgp_ipv4_neighbors_cmd,
  7335. "show ip bgp ipv4 (unicast|multicast) neighbors",
  7336. SHOW_STR
  7337. IP_STR
  7338. BGP_STR
  7339. "Address family\n"
  7340. "Address Family modifier\n"
  7341. "Address Family modifier\n"
  7342. "Detailed information on TCP and BGP neighbor connections\n")
  7343. ALIAS (show_ip_bgp_neighbors,
  7344. show_ip_bgp_vpnv4_all_neighbors_cmd,
  7345. "show ip bgp vpnv4 all neighbors",
  7346. SHOW_STR
  7347. IP_STR
  7348. BGP_STR
  7349. "Display VPNv4 NLRI specific information\n"
  7350. "Display information about all VPNv4 NLRIs\n"
  7351. "Detailed information on TCP and BGP neighbor connections\n")
  7352. ALIAS (show_ip_bgp_neighbors,
  7353. show_ip_bgp_vpnv4_rd_neighbors_cmd,
  7354. "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn neighbors",
  7355. SHOW_STR
  7356. IP_STR
  7357. BGP_STR
  7358. "Display VPNv4 NLRI specific information\n"
  7359. "Display information for a route distinguisher\n"
  7360. "VPN Route Distinguisher\n"
  7361. "Detailed information on TCP and BGP neighbor connections\n")
  7362. ALIAS (show_ip_bgp_neighbors,
  7363. show_bgp_neighbors_cmd,
  7364. "show bgp neighbors",
  7365. SHOW_STR
  7366. BGP_STR
  7367. "Detailed information on TCP and BGP neighbor connections\n")
  7368. ALIAS (show_ip_bgp_neighbors,
  7369. show_bgp_ipv6_neighbors_cmd,
  7370. "show bgp ipv6 neighbors",
  7371. SHOW_STR
  7372. BGP_STR
  7373. "Address family\n"
  7374. "Detailed information on TCP and BGP neighbor connections\n")
  7375. DEFUN (show_ip_bgp_neighbors_peer,
  7376. show_ip_bgp_neighbors_peer_cmd,
  7377. "show ip bgp neighbors (A.B.C.D|X:X::X:X)",
  7378. SHOW_STR
  7379. IP_STR
  7380. BGP_STR
  7381. "Detailed information on TCP and BGP neighbor connections\n"
  7382. "Neighbor to display information about\n"
  7383. "Neighbor to display information about\n")
  7384. {
  7385. return bgp_show_neighbor_vty (vty, NULL, show_peer, argv[argc - 1]);
  7386. }
  7387. ALIAS (show_ip_bgp_neighbors_peer,
  7388. show_ip_bgp_ipv4_neighbors_peer_cmd,
  7389. "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X)",
  7390. SHOW_STR
  7391. IP_STR
  7392. BGP_STR
  7393. "Address family\n"
  7394. "Address Family modifier\n"
  7395. "Address Family modifier\n"
  7396. "Detailed information on TCP and BGP neighbor connections\n"
  7397. "Neighbor to display information about\n"
  7398. "Neighbor to display information about\n")
  7399. ALIAS (show_ip_bgp_neighbors_peer,
  7400. show_ip_bgp_vpnv4_all_neighbors_peer_cmd,
  7401. "show ip bgp vpnv4 all neighbors A.B.C.D",
  7402. SHOW_STR
  7403. IP_STR
  7404. BGP_STR
  7405. "Display VPNv4 NLRI specific information\n"
  7406. "Display information about all VPNv4 NLRIs\n"
  7407. "Detailed information on TCP and BGP neighbor connections\n"
  7408. "Neighbor to display information about\n")
  7409. ALIAS (show_ip_bgp_neighbors_peer,
  7410. show_ip_bgp_vpnv4_rd_neighbors_peer_cmd,
  7411. "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn neighbors A.B.C.D",
  7412. SHOW_STR
  7413. IP_STR
  7414. BGP_STR
  7415. "Display VPNv4 NLRI specific information\n"
  7416. "Display information about all VPNv4 NLRIs\n"
  7417. "Detailed information on TCP and BGP neighbor connections\n"
  7418. "Neighbor to display information about\n")
  7419. ALIAS (show_ip_bgp_neighbors_peer,
  7420. show_bgp_neighbors_peer_cmd,
  7421. "show bgp neighbors (A.B.C.D|X:X::X:X)",
  7422. SHOW_STR
  7423. BGP_STR
  7424. "Detailed information on TCP and BGP neighbor connections\n"
  7425. "Neighbor to display information about\n"
  7426. "Neighbor to display information about\n")
  7427. ALIAS (show_ip_bgp_neighbors_peer,
  7428. show_bgp_ipv6_neighbors_peer_cmd,
  7429. "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X)",
  7430. SHOW_STR
  7431. BGP_STR
  7432. "Address family\n"
  7433. "Detailed information on TCP and BGP neighbor connections\n"
  7434. "Neighbor to display information about\n"
  7435. "Neighbor to display information about\n")
  7436. DEFUN (show_ip_bgp_instance_neighbors,
  7437. show_ip_bgp_instance_neighbors_cmd,
  7438. "show ip bgp view WORD neighbors",
  7439. SHOW_STR
  7440. IP_STR
  7441. BGP_STR
  7442. "BGP view\n"
  7443. "View name\n"
  7444. "Detailed information on TCP and BGP neighbor connections\n")
  7445. {
  7446. return bgp_show_neighbor_vty (vty, argv[0], show_all, NULL);
  7447. }
  7448. ALIAS (show_ip_bgp_instance_neighbors,
  7449. show_bgp_instance_neighbors_cmd,
  7450. "show bgp view WORD neighbors",
  7451. SHOW_STR
  7452. BGP_STR
  7453. "BGP view\n"
  7454. "View name\n"
  7455. "Detailed information on TCP and BGP neighbor connections\n")
  7456. ALIAS (show_ip_bgp_instance_neighbors,
  7457. show_bgp_instance_ipv6_neighbors_cmd,
  7458. "show bgp view WORD ipv6 neighbors",
  7459. SHOW_STR
  7460. BGP_STR
  7461. "BGP view\n"
  7462. "View name\n"
  7463. "Address family\n"
  7464. "Detailed information on TCP and BGP neighbor connections\n")
  7465. DEFUN (show_ip_bgp_instance_neighbors_peer,
  7466. show_ip_bgp_instance_neighbors_peer_cmd,
  7467. "show ip bgp view WORD neighbors (A.B.C.D|X:X::X:X)",
  7468. SHOW_STR
  7469. IP_STR
  7470. BGP_STR
  7471. "BGP view\n"
  7472. "View name\n"
  7473. "Detailed information on TCP and BGP neighbor connections\n"
  7474. "Neighbor to display information about\n"
  7475. "Neighbor to display information about\n")
  7476. {
  7477. return bgp_show_neighbor_vty (vty, argv[0], show_peer, argv[1]);
  7478. }
  7479. ALIAS (show_ip_bgp_instance_neighbors_peer,
  7480. show_bgp_instance_neighbors_peer_cmd,
  7481. "show bgp view WORD neighbors (A.B.C.D|X:X::X:X)",
  7482. SHOW_STR
  7483. BGP_STR
  7484. "BGP view\n"
  7485. "View name\n"
  7486. "Detailed information on TCP and BGP neighbor connections\n"
  7487. "Neighbor to display information about\n"
  7488. "Neighbor to display information about\n")
  7489. ALIAS (show_ip_bgp_instance_neighbors_peer,
  7490. show_bgp_instance_ipv6_neighbors_peer_cmd,
  7491. "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X)",
  7492. SHOW_STR
  7493. BGP_STR
  7494. "BGP view\n"
  7495. "View name\n"
  7496. "Address family\n"
  7497. "Detailed information on TCP and BGP neighbor connections\n"
  7498. "Neighbor to display information about\n"
  7499. "Neighbor to display information about\n")
  7500. /* Show BGP's AS paths internal data. There are both `show ip bgp
  7501. paths' and `show ip mbgp paths'. Those functions results are the
  7502. same.*/
  7503. DEFUN (show_ip_bgp_paths,
  7504. show_ip_bgp_paths_cmd,
  7505. "show ip bgp paths",
  7506. SHOW_STR
  7507. IP_STR
  7508. BGP_STR
  7509. "Path information\n")
  7510. {
  7511. vty_out (vty, "Address Refcnt Path%s", VTY_NEWLINE);
  7512. aspath_print_all_vty (vty);
  7513. return CMD_SUCCESS;
  7514. }
  7515. DEFUN (show_ip_bgp_ipv4_paths,
  7516. show_ip_bgp_ipv4_paths_cmd,
  7517. "show ip bgp ipv4 (unicast|multicast) paths",
  7518. SHOW_STR
  7519. IP_STR
  7520. BGP_STR
  7521. "Address family\n"
  7522. "Address Family modifier\n"
  7523. "Address Family modifier\n"
  7524. "Path information\n")
  7525. {
  7526. vty_out (vty, "Address Refcnt Path\r\n");
  7527. aspath_print_all_vty (vty);
  7528. return CMD_SUCCESS;
  7529. }
  7530. #include "hash.h"
  7531. static void
  7532. community_show_all_iterator (struct hash_backet *backet, struct vty *vty)
  7533. {
  7534. struct community *com;
  7535. com = (struct community *) backet->data;
  7536. vty_out (vty, "[%p] (%ld) %s%s", (void *)backet, com->refcnt,
  7537. community_str (com), VTY_NEWLINE);
  7538. }
  7539. /* Show BGP's community internal data. */
  7540. DEFUN (show_ip_bgp_community_info,
  7541. show_ip_bgp_community_info_cmd,
  7542. "show ip bgp community-info",
  7543. SHOW_STR
  7544. IP_STR
  7545. BGP_STR
  7546. "List all bgp community information\n")
  7547. {
  7548. vty_out (vty, "Address Refcnt Community%s", VTY_NEWLINE);
  7549. hash_iterate (community_hash (),
  7550. (void (*) (struct hash_backet *, void *))
  7551. community_show_all_iterator,
  7552. vty);
  7553. return CMD_SUCCESS;
  7554. }
  7555. DEFUN (show_ip_bgp_attr_info,
  7556. show_ip_bgp_attr_info_cmd,
  7557. "show ip bgp attribute-info",
  7558. SHOW_STR
  7559. IP_STR
  7560. BGP_STR
  7561. "List all bgp attribute information\n")
  7562. {
  7563. attr_show_all (vty);
  7564. return CMD_SUCCESS;
  7565. }
  7566. static int
  7567. bgp_write_rsclient_summary (struct vty *vty, struct peer *rsclient,
  7568. afi_t afi, safi_t safi)
  7569. {
  7570. char timebuf[BGP_UPTIME_LEN];
  7571. char rmbuf[14];
  7572. const char *rmname;
  7573. struct peer *peer;
  7574. struct listnode *node, *nnode;
  7575. int len;
  7576. int count = 0;
  7577. if (CHECK_FLAG (rsclient->sflags, PEER_STATUS_GROUP))
  7578. {
  7579. for (ALL_LIST_ELEMENTS (rsclient->group->peer, node, nnode, peer))
  7580. {
  7581. count++;
  7582. bgp_write_rsclient_summary (vty, peer, afi, safi);
  7583. }
  7584. return count;
  7585. }
  7586. len = vty_out (vty, "%s", rsclient->host);
  7587. len = 16 - len;
  7588. if (len < 1)
  7589. vty_out (vty, "%s%*s", VTY_NEWLINE, 16, " ");
  7590. else
  7591. vty_out (vty, "%*s", len, " ");
  7592. vty_out (vty, "4 ");
  7593. vty_out (vty, "%10u ", rsclient->as);
  7594. rmname = ROUTE_MAP_EXPORT_NAME(&rsclient->filter[afi][safi]);
  7595. if ( rmname && strlen (rmname) > 13 )
  7596. {
  7597. sprintf (rmbuf, "%13s", "...");
  7598. rmname = strncpy (rmbuf, rmname, 10);
  7599. }
  7600. else if (! rmname)
  7601. rmname = "<none>";
  7602. vty_out (vty, " %13s ", rmname);
  7603. rmname = ROUTE_MAP_IMPORT_NAME(&rsclient->filter[afi][safi]);
  7604. if ( rmname && strlen (rmname) > 13 )
  7605. {
  7606. sprintf (rmbuf, "%13s", "...");
  7607. rmname = strncpy (rmbuf, rmname, 10);
  7608. }
  7609. else if (! rmname)
  7610. rmname = "<none>";
  7611. vty_out (vty, " %13s ", rmname);
  7612. vty_out (vty, "%8s", peer_uptime (rsclient->uptime, timebuf, BGP_UPTIME_LEN));
  7613. if (CHECK_FLAG (rsclient->flags, PEER_FLAG_SHUTDOWN))
  7614. vty_out (vty, " Idle (Admin)");
  7615. else if (CHECK_FLAG (rsclient->sflags, PEER_STATUS_PREFIX_OVERFLOW))
  7616. vty_out (vty, " Idle (PfxCt)");
  7617. else
  7618. vty_out (vty, " %-11s", LOOKUP(bgp_status_msg, rsclient->status));
  7619. vty_out (vty, "%s", VTY_NEWLINE);
  7620. return 1;
  7621. }
  7622. static int
  7623. bgp_show_rsclient_summary (struct vty *vty, struct bgp *bgp,
  7624. afi_t afi, safi_t safi)
  7625. {
  7626. struct peer *peer;
  7627. struct listnode *node, *nnode;
  7628. int count = 0;
  7629. /* Header string for each address family. */
  7630. static char header[] = "Neighbor V AS Export-Policy Import-Policy Up/Down State";
  7631. for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, peer))
  7632. {
  7633. if (peer->afc[afi][safi] &&
  7634. CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
  7635. {
  7636. if (! count)
  7637. {
  7638. vty_out (vty,
  7639. "Route Server's BGP router identifier %s%s",
  7640. inet_ntoa (bgp->router_id), VTY_NEWLINE);
  7641. vty_out (vty,
  7642. "Route Server's local AS number %u%s", bgp->as,
  7643. VTY_NEWLINE);
  7644. vty_out (vty, "%s", VTY_NEWLINE);
  7645. vty_out (vty, "%s%s", header, VTY_NEWLINE);
  7646. }
  7647. count += bgp_write_rsclient_summary (vty, peer, afi, safi);
  7648. }
  7649. }
  7650. if (count)
  7651. vty_out (vty, "%sTotal number of Route Server Clients %d%s", VTY_NEWLINE,
  7652. count, VTY_NEWLINE);
  7653. else
  7654. vty_out (vty, "No %s Route Server Client is configured%s",
  7655. afi == AFI_IP ? "IPv4" : "IPv6", VTY_NEWLINE);
  7656. return CMD_SUCCESS;
  7657. }
  7658. static int
  7659. bgp_show_rsclient_summary_vty (struct vty *vty, const char *name,
  7660. afi_t afi, safi_t safi)
  7661. {
  7662. struct bgp *bgp;
  7663. if (name)
  7664. {
  7665. bgp = bgp_lookup_by_name (name);
  7666. if (! bgp)
  7667. {
  7668. vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE);
  7669. return CMD_WARNING;
  7670. }
  7671. bgp_show_rsclient_summary (vty, bgp, afi, safi);
  7672. return CMD_SUCCESS;
  7673. }
  7674. bgp = bgp_get_default ();
  7675. if (bgp)
  7676. bgp_show_rsclient_summary (vty, bgp, afi, safi);
  7677. return CMD_SUCCESS;
  7678. }
  7679. /* 'show bgp rsclient' commands. */
  7680. DEFUN (show_ip_bgp_rsclient_summary,
  7681. show_ip_bgp_rsclient_summary_cmd,
  7682. "show ip bgp rsclient summary",
  7683. SHOW_STR
  7684. IP_STR
  7685. BGP_STR
  7686. "Information about Route Server Clients\n"
  7687. "Summary of all Route Server Clients\n")
  7688. {
  7689. return bgp_show_rsclient_summary_vty (vty, NULL, AFI_IP, SAFI_UNICAST);
  7690. }
  7691. DEFUN (show_ip_bgp_instance_rsclient_summary,
  7692. show_ip_bgp_instance_rsclient_summary_cmd,
  7693. "show ip bgp view WORD rsclient summary",
  7694. SHOW_STR
  7695. IP_STR
  7696. BGP_STR
  7697. "BGP view\n"
  7698. "View name\n"
  7699. "Information about Route Server Clients\n"
  7700. "Summary of all Route Server Clients\n")
  7701. {
  7702. return bgp_show_rsclient_summary_vty (vty, argv[0], AFI_IP, SAFI_UNICAST);
  7703. }
  7704. DEFUN (show_ip_bgp_ipv4_rsclient_summary,
  7705. show_ip_bgp_ipv4_rsclient_summary_cmd,
  7706. "show ip bgp ipv4 (unicast|multicast) rsclient summary",
  7707. SHOW_STR
  7708. IP_STR
  7709. BGP_STR
  7710. "Address family\n"
  7711. "Address Family modifier\n"
  7712. "Address Family modifier\n"
  7713. "Information about Route Server Clients\n"
  7714. "Summary of all Route Server Clients\n")
  7715. {
  7716. if (strncmp (argv[0], "m", 1) == 0)
  7717. return bgp_show_rsclient_summary_vty (vty, NULL, AFI_IP, SAFI_MULTICAST);
  7718. return bgp_show_rsclient_summary_vty (vty, NULL, AFI_IP, SAFI_UNICAST);
  7719. }
  7720. DEFUN (show_ip_bgp_instance_ipv4_rsclient_summary,
  7721. show_ip_bgp_instance_ipv4_rsclient_summary_cmd,
  7722. "show ip bgp view WORD ipv4 (unicast|multicast) rsclient summary",
  7723. SHOW_STR
  7724. IP_STR
  7725. BGP_STR
  7726. "BGP view\n"
  7727. "View name\n"
  7728. "Address family\n"
  7729. "Address Family modifier\n"
  7730. "Address Family modifier\n"
  7731. "Information about Route Server Clients\n"
  7732. "Summary of all Route Server Clients\n")
  7733. {
  7734. if (strncmp (argv[1], "m", 1) == 0)
  7735. return bgp_show_rsclient_summary_vty (vty, argv[0], AFI_IP, SAFI_MULTICAST);
  7736. return bgp_show_rsclient_summary_vty (vty, argv[0], AFI_IP, SAFI_UNICAST);
  7737. }
  7738. DEFUN (show_bgp_instance_ipv4_safi_rsclient_summary,
  7739. show_bgp_instance_ipv4_safi_rsclient_summary_cmd,
  7740. "show bgp view WORD ipv4 (unicast|multicast) rsclient summary",
  7741. SHOW_STR
  7742. BGP_STR
  7743. "BGP view\n"
  7744. "View name\n"
  7745. "Address family\n"
  7746. "Address Family modifier\n"
  7747. "Address Family modifier\n"
  7748. "Information about Route Server Clients\n"
  7749. "Summary of all Route Server Clients\n")
  7750. {
  7751. safi_t safi;
  7752. if (argc == 2) {
  7753. safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
  7754. return bgp_show_rsclient_summary_vty (vty, argv[0], AFI_IP, safi);
  7755. } else {
  7756. safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
  7757. return bgp_show_rsclient_summary_vty (vty, NULL, AFI_IP, safi);
  7758. }
  7759. }
  7760. ALIAS (show_bgp_instance_ipv4_safi_rsclient_summary,
  7761. show_bgp_ipv4_safi_rsclient_summary_cmd,
  7762. "show bgp ipv4 (unicast|multicast) rsclient summary",
  7763. SHOW_STR
  7764. BGP_STR
  7765. "Address family\n"
  7766. "Address Family modifier\n"
  7767. "Address Family modifier\n"
  7768. "Information about Route Server Clients\n"
  7769. "Summary of all Route Server Clients\n")
  7770. #ifdef HAVE_IPV6
  7771. DEFUN (show_bgp_rsclient_summary,
  7772. show_bgp_rsclient_summary_cmd,
  7773. "show bgp rsclient summary",
  7774. SHOW_STR
  7775. BGP_STR
  7776. "Information about Route Server Clients\n"
  7777. "Summary of all Route Server Clients\n")
  7778. {
  7779. return bgp_show_rsclient_summary_vty (vty, NULL, AFI_IP6, SAFI_UNICAST);
  7780. }
  7781. DEFUN (show_bgp_instance_rsclient_summary,
  7782. show_bgp_instance_rsclient_summary_cmd,
  7783. "show bgp view WORD rsclient summary",
  7784. SHOW_STR
  7785. BGP_STR
  7786. "BGP view\n"
  7787. "View name\n"
  7788. "Information about Route Server Clients\n"
  7789. "Summary of all Route Server Clients\n")
  7790. {
  7791. return bgp_show_rsclient_summary_vty (vty, argv[0], AFI_IP6, SAFI_UNICAST);
  7792. }
  7793. ALIAS (show_bgp_rsclient_summary,
  7794. show_bgp_ipv6_rsclient_summary_cmd,
  7795. "show bgp ipv6 rsclient summary",
  7796. SHOW_STR
  7797. BGP_STR
  7798. "Address family\n"
  7799. "Information about Route Server Clients\n"
  7800. "Summary of all Route Server Clients\n")
  7801. ALIAS (show_bgp_instance_rsclient_summary,
  7802. show_bgp_instance_ipv6_rsclient_summary_cmd,
  7803. "show bgp view WORD ipv6 rsclient summary",
  7804. SHOW_STR
  7805. BGP_STR
  7806. "BGP view\n"
  7807. "View name\n"
  7808. "Address family\n"
  7809. "Information about Route Server Clients\n"
  7810. "Summary of all Route Server Clients\n")
  7811. DEFUN (show_bgp_instance_ipv6_safi_rsclient_summary,
  7812. show_bgp_instance_ipv6_safi_rsclient_summary_cmd,
  7813. "show bgp view WORD ipv6 (unicast|multicast) rsclient summary",
  7814. SHOW_STR
  7815. BGP_STR
  7816. "BGP view\n"
  7817. "View name\n"
  7818. "Address family\n"
  7819. "Address Family modifier\n"
  7820. "Address Family modifier\n"
  7821. "Information about Route Server Clients\n"
  7822. "Summary of all Route Server Clients\n")
  7823. {
  7824. safi_t safi;
  7825. if (argc == 2) {
  7826. safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
  7827. return bgp_show_rsclient_summary_vty (vty, argv[0], AFI_IP6, safi);
  7828. } else {
  7829. safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
  7830. return bgp_show_rsclient_summary_vty (vty, NULL, AFI_IP6, safi);
  7831. }
  7832. }
  7833. ALIAS (show_bgp_instance_ipv6_safi_rsclient_summary,
  7834. show_bgp_ipv6_safi_rsclient_summary_cmd,
  7835. "show bgp ipv6 (unicast|multicast) rsclient summary",
  7836. SHOW_STR
  7837. BGP_STR
  7838. "Address family\n"
  7839. "Address Family modifier\n"
  7840. "Address Family modifier\n"
  7841. "Information about Route Server Clients\n"
  7842. "Summary of all Route Server Clients\n")
  7843. #endif /* HAVE IPV6 */
  7844. /* Redistribute VTY commands. */
  7845. DEFUN (bgp_redistribute_ipv4,
  7846. bgp_redistribute_ipv4_cmd,
  7847. "redistribute " QUAGGA_IP_REDIST_STR_BGPD,
  7848. "Redistribute information from another routing protocol\n"
  7849. QUAGGA_IP_REDIST_HELP_STR_BGPD)
  7850. {
  7851. int type;
  7852. type = proto_redistnum (AFI_IP, argv[0]);
  7853. if (type < 0 || type == ZEBRA_ROUTE_BGP)
  7854. {
  7855. vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
  7856. return CMD_WARNING;
  7857. }
  7858. return bgp_redistribute_set (vty->index, AFI_IP, type);
  7859. }
  7860. DEFUN (bgp_redistribute_ipv4_rmap,
  7861. bgp_redistribute_ipv4_rmap_cmd,
  7862. "redistribute " QUAGGA_IP_REDIST_STR_BGPD " route-map WORD",
  7863. "Redistribute information from another routing protocol\n"
  7864. QUAGGA_IP_REDIST_HELP_STR_BGPD
  7865. "Route map reference\n"
  7866. "Pointer to route-map entries\n")
  7867. {
  7868. int type;
  7869. type = proto_redistnum (AFI_IP, argv[0]);
  7870. if (type < 0 || type == ZEBRA_ROUTE_BGP)
  7871. {
  7872. vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
  7873. return CMD_WARNING;
  7874. }
  7875. bgp_redistribute_rmap_set (vty->index, AFI_IP, type, argv[1]);
  7876. return bgp_redistribute_set (vty->index, AFI_IP, type);
  7877. }
  7878. DEFUN (bgp_redistribute_ipv4_metric,
  7879. bgp_redistribute_ipv4_metric_cmd,
  7880. "redistribute " QUAGGA_IP_REDIST_STR_BGPD " metric <0-4294967295>",
  7881. "Redistribute information from another routing protocol\n"
  7882. QUAGGA_IP_REDIST_HELP_STR_BGPD
  7883. "Metric for redistributed routes\n"
  7884. "Default metric\n")
  7885. {
  7886. int type;
  7887. u_int32_t metric;
  7888. type = proto_redistnum (AFI_IP, argv[0]);
  7889. if (type < 0 || type == ZEBRA_ROUTE_BGP)
  7890. {
  7891. vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
  7892. return CMD_WARNING;
  7893. }
  7894. VTY_GET_INTEGER ("metric", metric, argv[1]);
  7895. bgp_redistribute_metric_set (vty->index, AFI_IP, type, metric);
  7896. return bgp_redistribute_set (vty->index, AFI_IP, type);
  7897. }
  7898. DEFUN (bgp_redistribute_ipv4_rmap_metric,
  7899. bgp_redistribute_ipv4_rmap_metric_cmd,
  7900. "redistribute " QUAGGA_IP_REDIST_STR_BGPD " route-map WORD metric <0-4294967295>",
  7901. "Redistribute information from another routing protocol\n"
  7902. QUAGGA_IP_REDIST_HELP_STR_BGPD
  7903. "Route map reference\n"
  7904. "Pointer to route-map entries\n"
  7905. "Metric for redistributed routes\n"
  7906. "Default metric\n")
  7907. {
  7908. int type;
  7909. u_int32_t metric;
  7910. type = proto_redistnum (AFI_IP, argv[0]);
  7911. if (type < 0 || type == ZEBRA_ROUTE_BGP)
  7912. {
  7913. vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
  7914. return CMD_WARNING;
  7915. }
  7916. VTY_GET_INTEGER ("metric", metric, argv[2]);
  7917. bgp_redistribute_rmap_set (vty->index, AFI_IP, type, argv[1]);
  7918. bgp_redistribute_metric_set (vty->index, AFI_IP, type, metric);
  7919. return bgp_redistribute_set (vty->index, AFI_IP, type);
  7920. }
  7921. DEFUN (bgp_redistribute_ipv4_metric_rmap,
  7922. bgp_redistribute_ipv4_metric_rmap_cmd,
  7923. "redistribute " QUAGGA_IP_REDIST_STR_BGPD " metric <0-4294967295> route-map WORD",
  7924. "Redistribute information from another routing protocol\n"
  7925. QUAGGA_IP_REDIST_HELP_STR_BGPD
  7926. "Metric for redistributed routes\n"
  7927. "Default metric\n"
  7928. "Route map reference\n"
  7929. "Pointer to route-map entries\n")
  7930. {
  7931. int type;
  7932. u_int32_t metric;
  7933. type = proto_redistnum (AFI_IP, argv[0]);
  7934. if (type < 0 || type == ZEBRA_ROUTE_BGP)
  7935. {
  7936. vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
  7937. return CMD_WARNING;
  7938. }
  7939. VTY_GET_INTEGER ("metric", metric, argv[1]);
  7940. bgp_redistribute_metric_set (vty->index, AFI_IP, type, metric);
  7941. bgp_redistribute_rmap_set (vty->index, AFI_IP, type, argv[2]);
  7942. return bgp_redistribute_set (vty->index, AFI_IP, type);
  7943. }
  7944. DEFUN (no_bgp_redistribute_ipv4,
  7945. no_bgp_redistribute_ipv4_cmd,
  7946. "no redistribute " QUAGGA_IP_REDIST_STR_BGPD,
  7947. NO_STR
  7948. "Redistribute information from another routing protocol\n"
  7949. QUAGGA_IP_REDIST_HELP_STR_BGPD)
  7950. {
  7951. int type;
  7952. type = proto_redistnum (AFI_IP, argv[0]);
  7953. if (type < 0 || type == ZEBRA_ROUTE_BGP)
  7954. {
  7955. vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
  7956. return CMD_WARNING;
  7957. }
  7958. return bgp_redistribute_unset (vty->index, AFI_IP, type);
  7959. }
  7960. DEFUN (no_bgp_redistribute_ipv4_rmap,
  7961. no_bgp_redistribute_ipv4_rmap_cmd,
  7962. "no redistribute " QUAGGA_IP_REDIST_STR_BGPD " route-map WORD",
  7963. NO_STR
  7964. "Redistribute information from another routing protocol\n"
  7965. QUAGGA_IP_REDIST_HELP_STR_BGPD
  7966. "Route map reference\n"
  7967. "Pointer to route-map entries\n")
  7968. {
  7969. int type;
  7970. type = proto_redistnum (AFI_IP, argv[0]);
  7971. if (type < 0 || type == ZEBRA_ROUTE_BGP)
  7972. {
  7973. vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
  7974. return CMD_WARNING;
  7975. }
  7976. bgp_redistribute_routemap_unset (vty->index, AFI_IP, type);
  7977. return CMD_SUCCESS;
  7978. }
  7979. DEFUN (no_bgp_redistribute_ipv4_metric,
  7980. no_bgp_redistribute_ipv4_metric_cmd,
  7981. "no redistribute " QUAGGA_IP_REDIST_STR_BGPD " metric <0-4294967295>",
  7982. NO_STR
  7983. "Redistribute information from another routing protocol\n"
  7984. QUAGGA_IP_REDIST_HELP_STR_BGPD
  7985. "Metric for redistributed routes\n"
  7986. "Default metric\n")
  7987. {
  7988. int type;
  7989. type = proto_redistnum (AFI_IP, argv[0]);
  7990. if (type < 0 || type == ZEBRA_ROUTE_BGP)
  7991. {
  7992. vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
  7993. return CMD_WARNING;
  7994. }
  7995. bgp_redistribute_metric_unset (vty->index, AFI_IP, type);
  7996. return CMD_SUCCESS;
  7997. }
  7998. DEFUN (no_bgp_redistribute_ipv4_rmap_metric,
  7999. no_bgp_redistribute_ipv4_rmap_metric_cmd,
  8000. "no redistribute " QUAGGA_IP_REDIST_STR_BGPD " route-map WORD metric <0-4294967295>",
  8001. NO_STR
  8002. "Redistribute information from another routing protocol\n"
  8003. QUAGGA_IP_REDIST_HELP_STR_BGPD
  8004. "Route map reference\n"
  8005. "Pointer to route-map entries\n"
  8006. "Metric for redistributed routes\n"
  8007. "Default metric\n")
  8008. {
  8009. int type;
  8010. type = proto_redistnum (AFI_IP, argv[0]);
  8011. if (type < 0 || type == ZEBRA_ROUTE_BGP)
  8012. {
  8013. vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
  8014. return CMD_WARNING;
  8015. }
  8016. bgp_redistribute_metric_unset (vty->index, AFI_IP, type);
  8017. bgp_redistribute_routemap_unset (vty->index, AFI_IP, type);
  8018. return CMD_SUCCESS;
  8019. }
  8020. ALIAS (no_bgp_redistribute_ipv4_rmap_metric,
  8021. no_bgp_redistribute_ipv4_metric_rmap_cmd,
  8022. "no redistribute " QUAGGA_IP_REDIST_STR_BGPD " metric <0-4294967295> route-map WORD",
  8023. NO_STR
  8024. "Redistribute information from another routing protocol\n"
  8025. QUAGGA_IP_REDIST_HELP_STR_BGPD
  8026. "Metric for redistributed routes\n"
  8027. "Default metric\n"
  8028. "Route map reference\n"
  8029. "Pointer to route-map entries\n")
  8030. #ifdef HAVE_IPV6
  8031. DEFUN (bgp_redistribute_ipv6,
  8032. bgp_redistribute_ipv6_cmd,
  8033. "redistribute " QUAGGA_IP6_REDIST_STR_BGPD,
  8034. "Redistribute information from another routing protocol\n"
  8035. QUAGGA_IP6_REDIST_HELP_STR_BGPD)
  8036. {
  8037. int type;
  8038. type = proto_redistnum (AFI_IP6, argv[0]);
  8039. if (type < 0 || type == ZEBRA_ROUTE_BGP)
  8040. {
  8041. vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
  8042. return CMD_WARNING;
  8043. }
  8044. return bgp_redistribute_set (vty->index, AFI_IP6, type);
  8045. }
  8046. DEFUN (bgp_redistribute_ipv6_rmap,
  8047. bgp_redistribute_ipv6_rmap_cmd,
  8048. "redistribute " QUAGGA_IP6_REDIST_STR_BGPD " route-map WORD",
  8049. "Redistribute information from another routing protocol\n"
  8050. QUAGGA_IP6_REDIST_HELP_STR_BGPD
  8051. "Route map reference\n"
  8052. "Pointer to route-map entries\n")
  8053. {
  8054. int type;
  8055. type = proto_redistnum (AFI_IP6, argv[0]);
  8056. if (type < 0 || type == ZEBRA_ROUTE_BGP)
  8057. {
  8058. vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
  8059. return CMD_WARNING;
  8060. }
  8061. bgp_redistribute_rmap_set (vty->index, AFI_IP6, type, argv[1]);
  8062. return bgp_redistribute_set (vty->index, AFI_IP6, type);
  8063. }
  8064. DEFUN (bgp_redistribute_ipv6_metric,
  8065. bgp_redistribute_ipv6_metric_cmd,
  8066. "redistribute " QUAGGA_IP6_REDIST_STR_BGPD " metric <0-4294967295>",
  8067. "Redistribute information from another routing protocol\n"
  8068. QUAGGA_IP6_REDIST_HELP_STR_BGPD
  8069. "Metric for redistributed routes\n"
  8070. "Default metric\n")
  8071. {
  8072. int type;
  8073. u_int32_t metric;
  8074. type = proto_redistnum (AFI_IP6, argv[0]);
  8075. if (type < 0 || type == ZEBRA_ROUTE_BGP)
  8076. {
  8077. vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
  8078. return CMD_WARNING;
  8079. }
  8080. VTY_GET_INTEGER ("metric", metric, argv[1]);
  8081. bgp_redistribute_metric_set (vty->index, AFI_IP6, type, metric);
  8082. return bgp_redistribute_set (vty->index, AFI_IP6, type);
  8083. }
  8084. DEFUN (bgp_redistribute_ipv6_rmap_metric,
  8085. bgp_redistribute_ipv6_rmap_metric_cmd,
  8086. "redistribute " QUAGGA_IP6_REDIST_STR_BGPD " route-map WORD metric <0-4294967295>",
  8087. "Redistribute information from another routing protocol\n"
  8088. QUAGGA_IP6_REDIST_HELP_STR_BGPD
  8089. "Route map reference\n"
  8090. "Pointer to route-map entries\n"
  8091. "Metric for redistributed routes\n"
  8092. "Default metric\n")
  8093. {
  8094. int type;
  8095. u_int32_t metric;
  8096. type = proto_redistnum (AFI_IP6, argv[0]);
  8097. if (type < 0 || type == ZEBRA_ROUTE_BGP)
  8098. {
  8099. vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
  8100. return CMD_WARNING;
  8101. }
  8102. VTY_GET_INTEGER ("metric", metric, argv[2]);
  8103. bgp_redistribute_rmap_set (vty->index, AFI_IP6, type, argv[1]);
  8104. bgp_redistribute_metric_set (vty->index, AFI_IP6, type, metric);
  8105. return bgp_redistribute_set (vty->index, AFI_IP6, type);
  8106. }
  8107. DEFUN (bgp_redistribute_ipv6_metric_rmap,
  8108. bgp_redistribute_ipv6_metric_rmap_cmd,
  8109. "redistribute " QUAGGA_IP6_REDIST_STR_BGPD " metric <0-4294967295> route-map WORD",
  8110. "Redistribute information from another routing protocol\n"
  8111. QUAGGA_IP6_REDIST_HELP_STR_BGPD
  8112. "Metric for redistributed routes\n"
  8113. "Default metric\n"
  8114. "Route map reference\n"
  8115. "Pointer to route-map entries\n")
  8116. {
  8117. int type;
  8118. u_int32_t metric;
  8119. type = proto_redistnum (AFI_IP6, argv[0]);
  8120. if (type < 0 || type == ZEBRA_ROUTE_BGP)
  8121. {
  8122. vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
  8123. return CMD_WARNING;
  8124. }
  8125. VTY_GET_INTEGER ("metric", metric, argv[1]);
  8126. bgp_redistribute_metric_set (vty->index, AFI_IP6, type, metric);
  8127. bgp_redistribute_rmap_set (vty->index, AFI_IP6, type, argv[2]);
  8128. return bgp_redistribute_set (vty->index, AFI_IP6, type);
  8129. }
  8130. DEFUN (no_bgp_redistribute_ipv6,
  8131. no_bgp_redistribute_ipv6_cmd,
  8132. "no redistribute " QUAGGA_IP6_REDIST_STR_BGPD,
  8133. NO_STR
  8134. "Redistribute information from another routing protocol\n"
  8135. QUAGGA_IP6_REDIST_HELP_STR_BGPD)
  8136. {
  8137. int type;
  8138. type = proto_redistnum (AFI_IP6, argv[0]);
  8139. if (type < 0 || type == ZEBRA_ROUTE_BGP)
  8140. {
  8141. vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
  8142. return CMD_WARNING;
  8143. }
  8144. return bgp_redistribute_unset (vty->index, AFI_IP6, type);
  8145. }
  8146. DEFUN (no_bgp_redistribute_ipv6_rmap,
  8147. no_bgp_redistribute_ipv6_rmap_cmd,
  8148. "no redistribute " QUAGGA_IP6_REDIST_STR_BGPD " route-map WORD",
  8149. NO_STR
  8150. "Redistribute information from another routing protocol\n"
  8151. QUAGGA_IP6_REDIST_HELP_STR_BGPD
  8152. "Route map reference\n"
  8153. "Pointer to route-map entries\n")
  8154. {
  8155. int type;
  8156. type = proto_redistnum (AFI_IP6, argv[0]);
  8157. if (type < 0 || type == ZEBRA_ROUTE_BGP)
  8158. {
  8159. vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
  8160. return CMD_WARNING;
  8161. }
  8162. bgp_redistribute_routemap_unset (vty->index, AFI_IP6, type);
  8163. return CMD_SUCCESS;
  8164. }
  8165. DEFUN (no_bgp_redistribute_ipv6_metric,
  8166. no_bgp_redistribute_ipv6_metric_cmd,
  8167. "no redistribute " QUAGGA_IP6_REDIST_STR_BGPD " metric <0-4294967295>",
  8168. NO_STR
  8169. "Redistribute information from another routing protocol\n"
  8170. QUAGGA_IP6_REDIST_HELP_STR_BGPD
  8171. "Metric for redistributed routes\n"
  8172. "Default metric\n")
  8173. {
  8174. int type;
  8175. type = proto_redistnum (AFI_IP6, argv[0]);
  8176. if (type < 0 || type == ZEBRA_ROUTE_BGP)
  8177. {
  8178. vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
  8179. return CMD_WARNING;
  8180. }
  8181. bgp_redistribute_metric_unset (vty->index, AFI_IP6, type);
  8182. return CMD_SUCCESS;
  8183. }
  8184. DEFUN (no_bgp_redistribute_ipv6_rmap_metric,
  8185. no_bgp_redistribute_ipv6_rmap_metric_cmd,
  8186. "no redistribute " QUAGGA_IP6_REDIST_STR_BGPD " route-map WORD metric <0-4294967295>",
  8187. NO_STR
  8188. "Redistribute information from another routing protocol\n"
  8189. QUAGGA_IP6_REDIST_HELP_STR_BGPD
  8190. "Route map reference\n"
  8191. "Pointer to route-map entries\n"
  8192. "Metric for redistributed routes\n"
  8193. "Default metric\n")
  8194. {
  8195. int type;
  8196. type = proto_redistnum (AFI_IP6, argv[0]);
  8197. if (type < 0 || type == ZEBRA_ROUTE_BGP)
  8198. {
  8199. vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
  8200. return CMD_WARNING;
  8201. }
  8202. bgp_redistribute_metric_unset (vty->index, AFI_IP6, type);
  8203. bgp_redistribute_routemap_unset (vty->index, AFI_IP6, type);
  8204. return CMD_SUCCESS;
  8205. }
  8206. ALIAS (no_bgp_redistribute_ipv6_rmap_metric,
  8207. no_bgp_redistribute_ipv6_metric_rmap_cmd,
  8208. "no redistribute " QUAGGA_IP6_REDIST_STR_BGPD " metric <0-4294967295> route-map WORD",
  8209. NO_STR
  8210. "Redistribute information from another routing protocol\n"
  8211. QUAGGA_IP6_REDIST_HELP_STR_BGPD
  8212. "Metric for redistributed routes\n"
  8213. "Default metric\n"
  8214. "Route map reference\n"
  8215. "Pointer to route-map entries\n")
  8216. #endif /* HAVE_IPV6 */
  8217. int
  8218. bgp_config_write_redistribute (struct vty *vty, struct bgp *bgp, afi_t afi,
  8219. safi_t safi, int *write)
  8220. {
  8221. int i;
  8222. /* Unicast redistribution only. */
  8223. if (safi != SAFI_UNICAST)
  8224. return 0;
  8225. for (i = 0; i < ZEBRA_ROUTE_MAX; i++)
  8226. {
  8227. /* Redistribute BGP does not make sense. */
  8228. if (bgp->redist[afi][i] && i != ZEBRA_ROUTE_BGP)
  8229. {
  8230. /* Display "address-family" when it is not yet diplayed. */
  8231. bgp_config_write_family_header (vty, afi, safi, write);
  8232. /* "redistribute" configuration. */
  8233. vty_out (vty, " redistribute %s", zebra_route_string(i));
  8234. if (bgp->redist_metric_flag[afi][i])
  8235. vty_out (vty, " metric %u", bgp->redist_metric[afi][i]);
  8236. if (bgp->rmap[afi][i].name)
  8237. vty_out (vty, " route-map %s", bgp->rmap[afi][i].name);
  8238. vty_out (vty, "%s", VTY_NEWLINE);
  8239. }
  8240. }
  8241. return *write;
  8242. }
  8243. /* BGP node structure. */
  8244. static struct cmd_node bgp_node =
  8245. {
  8246. BGP_NODE,
  8247. "%s(config-router)# ",
  8248. 1,
  8249. };
  8250. static struct cmd_node bgp_ipv4_unicast_node =
  8251. {
  8252. BGP_IPV4_NODE,
  8253. "%s(config-router-af)# ",
  8254. 1,
  8255. };
  8256. static struct cmd_node bgp_ipv4_multicast_node =
  8257. {
  8258. BGP_IPV4M_NODE,
  8259. "%s(config-router-af)# ",
  8260. 1,
  8261. };
  8262. static struct cmd_node bgp_ipv6_unicast_node =
  8263. {
  8264. BGP_IPV6_NODE,
  8265. "%s(config-router-af)# ",
  8266. 1,
  8267. };
  8268. static struct cmd_node bgp_ipv6_multicast_node =
  8269. {
  8270. BGP_IPV6M_NODE,
  8271. "%s(config-router-af)# ",
  8272. 1,
  8273. };
  8274. static struct cmd_node bgp_vpnv4_node =
  8275. {
  8276. BGP_VPNV4_NODE,
  8277. "%s(config-router-af)# ",
  8278. 1
  8279. };
  8280. static struct cmd_node bgp_vpnv6_node =
  8281. {
  8282. BGP_VPNV6_NODE,
  8283. "%s(config-router-af-vpnv6)# ",
  8284. 1
  8285. };
  8286. static struct cmd_node bgp_encap_node =
  8287. {
  8288. BGP_ENCAP_NODE,
  8289. "%s(config-router-af-encap)# ",
  8290. 1
  8291. };
  8292. static struct cmd_node bgp_encapv6_node =
  8293. {
  8294. BGP_ENCAPV6_NODE,
  8295. "%s(config-router-af-encapv6)# ",
  8296. 1
  8297. };
  8298. static void community_list_vty (void);
  8299. void
  8300. bgp_vty_init (void)
  8301. {
  8302. /* Install bgp top node. */
  8303. install_node (&bgp_node, bgp_config_write);
  8304. install_node (&bgp_ipv4_unicast_node, NULL);
  8305. install_node (&bgp_ipv4_multicast_node, NULL);
  8306. install_node (&bgp_ipv6_unicast_node, NULL);
  8307. install_node (&bgp_ipv6_multicast_node, NULL);
  8308. install_node (&bgp_vpnv4_node, NULL);
  8309. install_node (&bgp_vpnv6_node, NULL);
  8310. install_node (&bgp_encap_node, NULL);
  8311. install_node (&bgp_encapv6_node, NULL);
  8312. /* Install default VTY commands to new nodes. */
  8313. install_default (BGP_NODE);
  8314. install_default (BGP_IPV4_NODE);
  8315. install_default (BGP_IPV4M_NODE);
  8316. install_default (BGP_IPV6_NODE);
  8317. install_default (BGP_IPV6M_NODE);
  8318. install_default (BGP_VPNV4_NODE);
  8319. install_default (BGP_VPNV6_NODE);
  8320. install_default (BGP_ENCAP_NODE);
  8321. install_default (BGP_ENCAPV6_NODE);
  8322. /* "bgp multiple-instance" commands. */
  8323. install_element (CONFIG_NODE, &bgp_multiple_instance_cmd);
  8324. install_element (CONFIG_NODE, &no_bgp_multiple_instance_cmd);
  8325. /* "bgp config-type" commands. */
  8326. install_element (CONFIG_NODE, &bgp_config_type_cmd);
  8327. install_element (CONFIG_NODE, &no_bgp_config_type_cmd);
  8328. /* Dummy commands (Currently not supported) */
  8329. install_element (BGP_NODE, &no_synchronization_cmd);
  8330. install_element (BGP_NODE, &no_auto_summary_cmd);
  8331. /* "router bgp" commands. */
  8332. install_element (CONFIG_NODE, &router_bgp_cmd);
  8333. install_element (CONFIG_NODE, &router_bgp_view_cmd);
  8334. /* "no router bgp" commands. */
  8335. install_element (CONFIG_NODE, &no_router_bgp_cmd);
  8336. install_element (CONFIG_NODE, &no_router_bgp_view_cmd);
  8337. /* "bgp router-id" commands. */
  8338. install_element (BGP_NODE, &bgp_router_id_cmd);
  8339. install_element (BGP_NODE, &no_bgp_router_id_cmd);
  8340. install_element (BGP_NODE, &no_bgp_router_id_val_cmd);
  8341. /* "bgp cluster-id" commands. */
  8342. install_element (BGP_NODE, &bgp_cluster_id_cmd);
  8343. install_element (BGP_NODE, &bgp_cluster_id32_cmd);
  8344. install_element (BGP_NODE, &no_bgp_cluster_id_cmd);
  8345. install_element (BGP_NODE, &no_bgp_cluster_id_arg_cmd);
  8346. /* "bgp confederation" commands. */
  8347. install_element (BGP_NODE, &bgp_confederation_identifier_cmd);
  8348. install_element (BGP_NODE, &no_bgp_confederation_identifier_cmd);
  8349. install_element (BGP_NODE, &no_bgp_confederation_identifier_arg_cmd);
  8350. /* "bgp confederation peers" commands. */
  8351. install_element (BGP_NODE, &bgp_confederation_peers_cmd);
  8352. install_element (BGP_NODE, &no_bgp_confederation_peers_cmd);
  8353. /* "maximum-paths" commands. */
  8354. install_element (BGP_NODE, &bgp_maxpaths_cmd);
  8355. install_element (BGP_NODE, &no_bgp_maxpaths_cmd);
  8356. install_element (BGP_NODE, &no_bgp_maxpaths_arg_cmd);
  8357. install_element (BGP_IPV4_NODE, &bgp_maxpaths_cmd);
  8358. install_element (BGP_IPV4_NODE, &no_bgp_maxpaths_cmd);
  8359. install_element (BGP_IPV4_NODE, &no_bgp_maxpaths_arg_cmd);
  8360. install_element (BGP_NODE, &bgp_maxpaths_ibgp_cmd);
  8361. install_element (BGP_NODE, &no_bgp_maxpaths_ibgp_cmd);
  8362. install_element (BGP_NODE, &no_bgp_maxpaths_ibgp_arg_cmd);
  8363. install_element (BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cmd);
  8364. install_element (BGP_IPV4_NODE, &no_bgp_maxpaths_ibgp_cmd);
  8365. install_element (BGP_IPV4_NODE, &no_bgp_maxpaths_ibgp_arg_cmd);
  8366. /* "timers bgp" commands. */
  8367. install_element (BGP_NODE, &bgp_timers_cmd);
  8368. install_element (BGP_NODE, &no_bgp_timers_cmd);
  8369. install_element (BGP_NODE, &no_bgp_timers_arg_cmd);
  8370. /* "bgp client-to-client reflection" commands */
  8371. install_element (BGP_NODE, &no_bgp_client_to_client_reflection_cmd);
  8372. install_element (BGP_NODE, &bgp_client_to_client_reflection_cmd);
  8373. /* "bgp always-compare-med" commands */
  8374. install_element (BGP_NODE, &bgp_always_compare_med_cmd);
  8375. install_element (BGP_NODE, &no_bgp_always_compare_med_cmd);
  8376. /* "bgp deterministic-med" commands */
  8377. install_element (BGP_NODE, &bgp_deterministic_med_cmd);
  8378. install_element (BGP_NODE, &no_bgp_deterministic_med_cmd);
  8379. /* "bgp graceful-restart" commands */
  8380. install_element (BGP_NODE, &bgp_graceful_restart_cmd);
  8381. install_element (BGP_NODE, &no_bgp_graceful_restart_cmd);
  8382. install_element (BGP_NODE, &bgp_graceful_restart_stalepath_time_cmd);
  8383. install_element (BGP_NODE, &no_bgp_graceful_restart_stalepath_time_cmd);
  8384. install_element (BGP_NODE, &no_bgp_graceful_restart_stalepath_time_val_cmd);
  8385. /* "bgp fast-external-failover" commands */
  8386. install_element (BGP_NODE, &bgp_fast_external_failover_cmd);
  8387. install_element (BGP_NODE, &no_bgp_fast_external_failover_cmd);
  8388. /* "bgp enforce-first-as" commands */
  8389. install_element (BGP_NODE, &bgp_enforce_first_as_cmd);
  8390. install_element (BGP_NODE, &no_bgp_enforce_first_as_cmd);
  8391. /* "bgp bestpath compare-routerid" commands */
  8392. install_element (BGP_NODE, &bgp_bestpath_compare_router_id_cmd);
  8393. install_element (BGP_NODE, &no_bgp_bestpath_compare_router_id_cmd);
  8394. /* "bgp bestpath as-path ignore" commands */
  8395. install_element (BGP_NODE, &bgp_bestpath_aspath_ignore_cmd);
  8396. install_element (BGP_NODE, &no_bgp_bestpath_aspath_ignore_cmd);
  8397. /* "bgp bestpath as-path confed" commands */
  8398. install_element (BGP_NODE, &bgp_bestpath_aspath_confed_cmd);
  8399. install_element (BGP_NODE, &no_bgp_bestpath_aspath_confed_cmd);
  8400. /* "bgp bestpath as-path multipath-relax" commands */
  8401. install_element (BGP_NODE, &bgp_bestpath_aspath_multipath_relax_cmd);
  8402. install_element (BGP_NODE, &no_bgp_bestpath_aspath_multipath_relax_cmd);
  8403. /* "bgp log-neighbor-changes" commands */
  8404. install_element (BGP_NODE, &bgp_log_neighbor_changes_cmd);
  8405. install_element (BGP_NODE, &no_bgp_log_neighbor_changes_cmd);
  8406. /* "bgp bestpath med" commands */
  8407. install_element (BGP_NODE, &bgp_bestpath_med_cmd);
  8408. install_element (BGP_NODE, &bgp_bestpath_med2_cmd);
  8409. install_element (BGP_NODE, &bgp_bestpath_med3_cmd);
  8410. install_element (BGP_NODE, &no_bgp_bestpath_med_cmd);
  8411. install_element (BGP_NODE, &no_bgp_bestpath_med2_cmd);
  8412. install_element (BGP_NODE, &no_bgp_bestpath_med3_cmd);
  8413. /* "no bgp default ipv4-unicast" commands. */
  8414. install_element (BGP_NODE, &no_bgp_default_ipv4_unicast_cmd);
  8415. install_element (BGP_NODE, &bgp_default_ipv4_unicast_cmd);
  8416. /* "bgp network import-check" commands. */
  8417. install_element (BGP_NODE, &bgp_network_import_check_cmd);
  8418. install_element (BGP_NODE, &no_bgp_network_import_check_cmd);
  8419. /* "bgp default local-preference" commands. */
  8420. install_element (BGP_NODE, &bgp_default_local_preference_cmd);
  8421. install_element (BGP_NODE, &no_bgp_default_local_preference_cmd);
  8422. install_element (BGP_NODE, &no_bgp_default_local_preference_val_cmd);
  8423. /* "neighbor remote-as" commands. */
  8424. install_element (BGP_NODE, &neighbor_remote_as_cmd);
  8425. install_element (BGP_NODE, &no_neighbor_cmd);
  8426. install_element (BGP_NODE, &no_neighbor_remote_as_cmd);
  8427. /* "neighbor peer-group" commands. */
  8428. install_element (BGP_NODE, &neighbor_peer_group_cmd);
  8429. install_element (BGP_NODE, &no_neighbor_peer_group_cmd);
  8430. install_element (BGP_NODE, &no_neighbor_peer_group_remote_as_cmd);
  8431. /* "neighbor local-as" commands. */
  8432. install_element (BGP_NODE, &neighbor_local_as_cmd);
  8433. install_element (BGP_NODE, &neighbor_local_as_no_prepend_cmd);
  8434. install_element (BGP_NODE, &neighbor_local_as_no_prepend_replace_as_cmd);
  8435. install_element (BGP_NODE, &no_neighbor_local_as_cmd);
  8436. install_element (BGP_NODE, &no_neighbor_local_as_val_cmd);
  8437. install_element (BGP_NODE, &no_neighbor_local_as_val2_cmd);
  8438. install_element (BGP_NODE, &no_neighbor_local_as_val3_cmd);
  8439. /* "neighbor password" commands. */
  8440. install_element (BGP_NODE, &neighbor_password_cmd);
  8441. install_element (BGP_NODE, &no_neighbor_password_cmd);
  8442. /* "neighbor activate" commands. */
  8443. install_element (BGP_NODE, &neighbor_activate_cmd);
  8444. install_element (BGP_IPV4_NODE, &neighbor_activate_cmd);
  8445. install_element (BGP_IPV4M_NODE, &neighbor_activate_cmd);
  8446. install_element (BGP_IPV6_NODE, &neighbor_activate_cmd);
  8447. install_element (BGP_IPV6M_NODE, &neighbor_activate_cmd);
  8448. install_element (BGP_VPNV4_NODE, &neighbor_activate_cmd);
  8449. install_element (BGP_VPNV6_NODE, &neighbor_activate_cmd);
  8450. install_element (BGP_ENCAP_NODE, &neighbor_activate_cmd);
  8451. install_element (BGP_ENCAPV6_NODE, &neighbor_activate_cmd);
  8452. /* "no neighbor activate" commands. */
  8453. install_element (BGP_NODE, &no_neighbor_activate_cmd);
  8454. install_element (BGP_IPV4_NODE, &no_neighbor_activate_cmd);
  8455. install_element (BGP_IPV4M_NODE, &no_neighbor_activate_cmd);
  8456. install_element (BGP_IPV6_NODE, &no_neighbor_activate_cmd);
  8457. install_element (BGP_IPV6M_NODE, &no_neighbor_activate_cmd);
  8458. install_element (BGP_VPNV4_NODE, &no_neighbor_activate_cmd);
  8459. install_element (BGP_VPNV6_NODE, &no_neighbor_activate_cmd);
  8460. install_element (BGP_ENCAP_NODE, &no_neighbor_activate_cmd);
  8461. install_element (BGP_ENCAPV6_NODE, &no_neighbor_activate_cmd);
  8462. /* "neighbor peer-group set" commands. */
  8463. install_element (BGP_NODE, &neighbor_set_peer_group_cmd);
  8464. install_element (BGP_IPV4_NODE, &neighbor_set_peer_group_cmd);
  8465. install_element (BGP_IPV4M_NODE, &neighbor_set_peer_group_cmd);
  8466. install_element (BGP_IPV6_NODE, &neighbor_set_peer_group_cmd);
  8467. install_element (BGP_IPV6M_NODE, &neighbor_set_peer_group_cmd);
  8468. install_element (BGP_VPNV4_NODE, &neighbor_set_peer_group_cmd);
  8469. install_element (BGP_VPNV6_NODE, &neighbor_set_peer_group_cmd);
  8470. install_element (BGP_ENCAP_NODE, &neighbor_set_peer_group_cmd);
  8471. install_element (BGP_ENCAPV6_NODE, &neighbor_set_peer_group_cmd);
  8472. /* "no neighbor peer-group unset" commands. */
  8473. install_element (BGP_NODE, &no_neighbor_set_peer_group_cmd);
  8474. install_element (BGP_IPV4_NODE, &no_neighbor_set_peer_group_cmd);
  8475. install_element (BGP_IPV4M_NODE, &no_neighbor_set_peer_group_cmd);
  8476. install_element (BGP_IPV6_NODE, &no_neighbor_set_peer_group_cmd);
  8477. install_element (BGP_IPV6M_NODE, &no_neighbor_set_peer_group_cmd);
  8478. install_element (BGP_VPNV4_NODE, &no_neighbor_set_peer_group_cmd);
  8479. install_element (BGP_VPNV6_NODE, &no_neighbor_set_peer_group_cmd);
  8480. install_element (BGP_ENCAP_NODE, &no_neighbor_set_peer_group_cmd);
  8481. install_element (BGP_ENCAPV6_NODE, &no_neighbor_set_peer_group_cmd);
  8482. /* "neighbor softreconfiguration inbound" commands.*/
  8483. install_element (BGP_NODE, &neighbor_soft_reconfiguration_cmd);
  8484. install_element (BGP_NODE, &no_neighbor_soft_reconfiguration_cmd);
  8485. install_element (BGP_IPV4_NODE, &neighbor_soft_reconfiguration_cmd);
  8486. install_element (BGP_IPV4_NODE, &no_neighbor_soft_reconfiguration_cmd);
  8487. install_element (BGP_IPV4M_NODE, &neighbor_soft_reconfiguration_cmd);
  8488. install_element (BGP_IPV4M_NODE, &no_neighbor_soft_reconfiguration_cmd);
  8489. install_element (BGP_IPV6_NODE, &neighbor_soft_reconfiguration_cmd);
  8490. install_element (BGP_IPV6_NODE, &no_neighbor_soft_reconfiguration_cmd);
  8491. install_element (BGP_IPV6M_NODE, &neighbor_soft_reconfiguration_cmd);
  8492. install_element (BGP_IPV6M_NODE, &no_neighbor_soft_reconfiguration_cmd);
  8493. install_element (BGP_VPNV4_NODE, &neighbor_soft_reconfiguration_cmd);
  8494. install_element (BGP_VPNV4_NODE, &no_neighbor_soft_reconfiguration_cmd);
  8495. install_element (BGP_VPNV6_NODE, &neighbor_soft_reconfiguration_cmd);
  8496. install_element (BGP_VPNV6_NODE, &no_neighbor_soft_reconfiguration_cmd);
  8497. install_element (BGP_ENCAP_NODE, &neighbor_soft_reconfiguration_cmd);
  8498. install_element (BGP_ENCAP_NODE, &no_neighbor_soft_reconfiguration_cmd);
  8499. install_element (BGP_ENCAPV6_NODE, &neighbor_soft_reconfiguration_cmd);
  8500. install_element (BGP_ENCAPV6_NODE, &no_neighbor_soft_reconfiguration_cmd);
  8501. /* "neighbor attribute-unchanged" commands. */
  8502. install_element (BGP_NODE, &neighbor_attr_unchanged_cmd);
  8503. install_element (BGP_NODE, &neighbor_attr_unchanged1_cmd);
  8504. install_element (BGP_NODE, &neighbor_attr_unchanged2_cmd);
  8505. install_element (BGP_NODE, &neighbor_attr_unchanged3_cmd);
  8506. install_element (BGP_NODE, &neighbor_attr_unchanged4_cmd);
  8507. install_element (BGP_NODE, &neighbor_attr_unchanged5_cmd);
  8508. install_element (BGP_NODE, &neighbor_attr_unchanged6_cmd);
  8509. install_element (BGP_NODE, &neighbor_attr_unchanged7_cmd);
  8510. install_element (BGP_NODE, &neighbor_attr_unchanged8_cmd);
  8511. install_element (BGP_NODE, &neighbor_attr_unchanged9_cmd);
  8512. install_element (BGP_NODE, &neighbor_attr_unchanged10_cmd);
  8513. install_element (BGP_NODE, &no_neighbor_attr_unchanged_cmd);
  8514. install_element (BGP_NODE, &no_neighbor_attr_unchanged1_cmd);
  8515. install_element (BGP_NODE, &no_neighbor_attr_unchanged2_cmd);
  8516. install_element (BGP_NODE, &no_neighbor_attr_unchanged3_cmd);
  8517. install_element (BGP_NODE, &no_neighbor_attr_unchanged4_cmd);
  8518. install_element (BGP_NODE, &no_neighbor_attr_unchanged5_cmd);
  8519. install_element (BGP_NODE, &no_neighbor_attr_unchanged6_cmd);
  8520. install_element (BGP_NODE, &no_neighbor_attr_unchanged7_cmd);
  8521. install_element (BGP_NODE, &no_neighbor_attr_unchanged8_cmd);
  8522. install_element (BGP_NODE, &no_neighbor_attr_unchanged9_cmd);
  8523. install_element (BGP_NODE, &no_neighbor_attr_unchanged10_cmd);
  8524. install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged_cmd);
  8525. install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged1_cmd);
  8526. install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged2_cmd);
  8527. install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged3_cmd);
  8528. install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged4_cmd);
  8529. install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged5_cmd);
  8530. install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged6_cmd);
  8531. install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged7_cmd);
  8532. install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged8_cmd);
  8533. install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged9_cmd);
  8534. install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged10_cmd);
  8535. install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged_cmd);
  8536. install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged1_cmd);
  8537. install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged2_cmd);
  8538. install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged3_cmd);
  8539. install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged4_cmd);
  8540. install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged5_cmd);
  8541. install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged6_cmd);
  8542. install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged7_cmd);
  8543. install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged8_cmd);
  8544. install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged9_cmd);
  8545. install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged10_cmd);
  8546. install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged_cmd);
  8547. install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged1_cmd);
  8548. install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged2_cmd);
  8549. install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged3_cmd);
  8550. install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged4_cmd);
  8551. install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged5_cmd);
  8552. install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged6_cmd);
  8553. install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged7_cmd);
  8554. install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged8_cmd);
  8555. install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged9_cmd);
  8556. install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged10_cmd);
  8557. install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged_cmd);
  8558. install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged1_cmd);
  8559. install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged2_cmd);
  8560. install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged3_cmd);
  8561. install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged4_cmd);
  8562. install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged5_cmd);
  8563. install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged6_cmd);
  8564. install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged7_cmd);
  8565. install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged8_cmd);
  8566. install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged9_cmd);
  8567. install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged10_cmd);
  8568. install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged_cmd);
  8569. install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged1_cmd);
  8570. install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged2_cmd);
  8571. install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged3_cmd);
  8572. install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged4_cmd);
  8573. install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged5_cmd);
  8574. install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged6_cmd);
  8575. install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged7_cmd);
  8576. install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged8_cmd);
  8577. install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged9_cmd);
  8578. install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged10_cmd);
  8579. install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged_cmd);
  8580. install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged1_cmd);
  8581. install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged2_cmd);
  8582. install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged3_cmd);
  8583. install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged4_cmd);
  8584. install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged5_cmd);
  8585. install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged6_cmd);
  8586. install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged7_cmd);
  8587. install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged8_cmd);
  8588. install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged9_cmd);
  8589. install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged10_cmd);
  8590. install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged_cmd);
  8591. install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged1_cmd);
  8592. install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged2_cmd);
  8593. install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged3_cmd);
  8594. install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged4_cmd);
  8595. install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged5_cmd);
  8596. install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged6_cmd);
  8597. install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged7_cmd);
  8598. install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged8_cmd);
  8599. install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged9_cmd);
  8600. install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged10_cmd);
  8601. install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged_cmd);
  8602. install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged1_cmd);
  8603. install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged2_cmd);
  8604. install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged3_cmd);
  8605. install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged4_cmd);
  8606. install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged5_cmd);
  8607. install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged6_cmd);
  8608. install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged7_cmd);
  8609. install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged8_cmd);
  8610. install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged9_cmd);
  8611. install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged10_cmd);
  8612. install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged_cmd);
  8613. install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged1_cmd);
  8614. install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged2_cmd);
  8615. install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged3_cmd);
  8616. install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged4_cmd);
  8617. install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged5_cmd);
  8618. install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged6_cmd);
  8619. install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged7_cmd);
  8620. install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged8_cmd);
  8621. install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged9_cmd);
  8622. install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged10_cmd);
  8623. install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged_cmd);
  8624. install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged1_cmd);
  8625. install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged2_cmd);
  8626. install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged3_cmd);
  8627. install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged4_cmd);
  8628. install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged5_cmd);
  8629. install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged6_cmd);
  8630. install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged7_cmd);
  8631. install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged8_cmd);
  8632. install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged9_cmd);
  8633. install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged10_cmd);
  8634. install_element (BGP_VPNV6_NODE, &neighbor_attr_unchanged_cmd);
  8635. install_element (BGP_VPNV6_NODE, &neighbor_attr_unchanged1_cmd);
  8636. install_element (BGP_VPNV6_NODE, &neighbor_attr_unchanged2_cmd);
  8637. install_element (BGP_VPNV6_NODE, &neighbor_attr_unchanged3_cmd);
  8638. install_element (BGP_VPNV6_NODE, &neighbor_attr_unchanged4_cmd);
  8639. install_element (BGP_VPNV6_NODE, &neighbor_attr_unchanged5_cmd);
  8640. install_element (BGP_VPNV6_NODE, &neighbor_attr_unchanged6_cmd);
  8641. install_element (BGP_VPNV6_NODE, &neighbor_attr_unchanged7_cmd);
  8642. install_element (BGP_VPNV6_NODE, &neighbor_attr_unchanged8_cmd);
  8643. install_element (BGP_VPNV6_NODE, &neighbor_attr_unchanged9_cmd);
  8644. install_element (BGP_VPNV6_NODE, &neighbor_attr_unchanged10_cmd);
  8645. install_element (BGP_VPNV6_NODE, &no_neighbor_attr_unchanged_cmd);
  8646. install_element (BGP_VPNV6_NODE, &no_neighbor_attr_unchanged1_cmd);
  8647. install_element (BGP_VPNV6_NODE, &no_neighbor_attr_unchanged2_cmd);
  8648. install_element (BGP_VPNV6_NODE, &no_neighbor_attr_unchanged3_cmd);
  8649. install_element (BGP_VPNV6_NODE, &no_neighbor_attr_unchanged4_cmd);
  8650. install_element (BGP_VPNV6_NODE, &no_neighbor_attr_unchanged5_cmd);
  8651. install_element (BGP_VPNV6_NODE, &no_neighbor_attr_unchanged6_cmd);
  8652. install_element (BGP_VPNV6_NODE, &no_neighbor_attr_unchanged7_cmd);
  8653. install_element (BGP_VPNV6_NODE, &no_neighbor_attr_unchanged8_cmd);
  8654. install_element (BGP_VPNV6_NODE, &no_neighbor_attr_unchanged9_cmd);
  8655. install_element (BGP_VPNV6_NODE, &no_neighbor_attr_unchanged10_cmd);
  8656. install_element (BGP_ENCAP_NODE, &neighbor_attr_unchanged_cmd);
  8657. install_element (BGP_ENCAP_NODE, &neighbor_attr_unchanged1_cmd);
  8658. install_element (BGP_ENCAP_NODE, &neighbor_attr_unchanged2_cmd);
  8659. install_element (BGP_ENCAP_NODE, &neighbor_attr_unchanged3_cmd);
  8660. install_element (BGP_ENCAP_NODE, &neighbor_attr_unchanged4_cmd);
  8661. install_element (BGP_ENCAP_NODE, &neighbor_attr_unchanged5_cmd);
  8662. install_element (BGP_ENCAP_NODE, &neighbor_attr_unchanged6_cmd);
  8663. install_element (BGP_ENCAP_NODE, &neighbor_attr_unchanged7_cmd);
  8664. install_element (BGP_ENCAP_NODE, &neighbor_attr_unchanged8_cmd);
  8665. install_element (BGP_ENCAP_NODE, &neighbor_attr_unchanged9_cmd);
  8666. install_element (BGP_ENCAP_NODE, &neighbor_attr_unchanged10_cmd);
  8667. install_element (BGP_ENCAP_NODE, &no_neighbor_attr_unchanged_cmd);
  8668. install_element (BGP_ENCAP_NODE, &no_neighbor_attr_unchanged1_cmd);
  8669. install_element (BGP_ENCAP_NODE, &no_neighbor_attr_unchanged2_cmd);
  8670. install_element (BGP_ENCAP_NODE, &no_neighbor_attr_unchanged3_cmd);
  8671. install_element (BGP_ENCAP_NODE, &no_neighbor_attr_unchanged4_cmd);
  8672. install_element (BGP_ENCAP_NODE, &no_neighbor_attr_unchanged5_cmd);
  8673. install_element (BGP_ENCAP_NODE, &no_neighbor_attr_unchanged6_cmd);
  8674. install_element (BGP_ENCAP_NODE, &no_neighbor_attr_unchanged7_cmd);
  8675. install_element (BGP_ENCAP_NODE, &no_neighbor_attr_unchanged8_cmd);
  8676. install_element (BGP_ENCAP_NODE, &no_neighbor_attr_unchanged9_cmd);
  8677. install_element (BGP_ENCAP_NODE, &no_neighbor_attr_unchanged10_cmd);
  8678. install_element (BGP_ENCAPV6_NODE, &neighbor_attr_unchanged_cmd);
  8679. install_element (BGP_ENCAPV6_NODE, &neighbor_attr_unchanged1_cmd);
  8680. install_element (BGP_ENCAPV6_NODE, &neighbor_attr_unchanged2_cmd);
  8681. install_element (BGP_ENCAPV6_NODE, &neighbor_attr_unchanged3_cmd);
  8682. install_element (BGP_ENCAPV6_NODE, &neighbor_attr_unchanged4_cmd);
  8683. install_element (BGP_ENCAPV6_NODE, &neighbor_attr_unchanged5_cmd);
  8684. install_element (BGP_ENCAPV6_NODE, &neighbor_attr_unchanged6_cmd);
  8685. install_element (BGP_ENCAPV6_NODE, &neighbor_attr_unchanged7_cmd);
  8686. install_element (BGP_ENCAPV6_NODE, &neighbor_attr_unchanged8_cmd);
  8687. install_element (BGP_ENCAPV6_NODE, &neighbor_attr_unchanged9_cmd);
  8688. install_element (BGP_ENCAPV6_NODE, &neighbor_attr_unchanged10_cmd);
  8689. install_element (BGP_ENCAPV6_NODE, &no_neighbor_attr_unchanged_cmd);
  8690. install_element (BGP_ENCAPV6_NODE, &no_neighbor_attr_unchanged1_cmd);
  8691. install_element (BGP_ENCAPV6_NODE, &no_neighbor_attr_unchanged2_cmd);
  8692. install_element (BGP_ENCAPV6_NODE, &no_neighbor_attr_unchanged3_cmd);
  8693. install_element (BGP_ENCAPV6_NODE, &no_neighbor_attr_unchanged4_cmd);
  8694. install_element (BGP_ENCAPV6_NODE, &no_neighbor_attr_unchanged5_cmd);
  8695. install_element (BGP_ENCAPV6_NODE, &no_neighbor_attr_unchanged6_cmd);
  8696. install_element (BGP_ENCAPV6_NODE, &no_neighbor_attr_unchanged7_cmd);
  8697. install_element (BGP_ENCAPV6_NODE, &no_neighbor_attr_unchanged8_cmd);
  8698. install_element (BGP_ENCAPV6_NODE, &no_neighbor_attr_unchanged9_cmd);
  8699. install_element (BGP_ENCAPV6_NODE, &no_neighbor_attr_unchanged10_cmd);
  8700. /* "nexthop-local unchanged" commands */
  8701. install_element (BGP_IPV6_NODE, &neighbor_nexthop_local_unchanged_cmd);
  8702. install_element (BGP_IPV6_NODE, &no_neighbor_nexthop_local_unchanged_cmd);
  8703. /* "transparent-as" and "transparent-nexthop" for old version
  8704. compatibility. */
  8705. install_element (BGP_NODE, &neighbor_transparent_as_cmd);
  8706. install_element (BGP_NODE, &neighbor_transparent_nexthop_cmd);
  8707. /* "neighbor next-hop-self" commands. */
  8708. install_element (BGP_NODE, &neighbor_nexthop_self_cmd);
  8709. install_element (BGP_NODE, &no_neighbor_nexthop_self_cmd);
  8710. install_element (BGP_IPV4_NODE, &neighbor_nexthop_self_cmd);
  8711. install_element (BGP_IPV4_NODE, &no_neighbor_nexthop_self_cmd);
  8712. install_element (BGP_IPV4M_NODE, &neighbor_nexthop_self_cmd);
  8713. install_element (BGP_IPV4M_NODE, &no_neighbor_nexthop_self_cmd);
  8714. install_element (BGP_IPV6_NODE, &neighbor_nexthop_self_cmd);
  8715. install_element (BGP_IPV6_NODE, &no_neighbor_nexthop_self_cmd);
  8716. install_element (BGP_IPV6M_NODE, &neighbor_nexthop_self_cmd);
  8717. install_element (BGP_IPV6M_NODE, &no_neighbor_nexthop_self_cmd);
  8718. install_element (BGP_VPNV4_NODE, &neighbor_nexthop_self_cmd);
  8719. install_element (BGP_VPNV4_NODE, &no_neighbor_nexthop_self_cmd);
  8720. install_element (BGP_VPNV6_NODE, &neighbor_nexthop_self_cmd);
  8721. install_element (BGP_VPNV6_NODE, &no_neighbor_nexthop_self_cmd);
  8722. install_element (BGP_ENCAP_NODE, &neighbor_nexthop_self_cmd);
  8723. install_element (BGP_ENCAP_NODE, &no_neighbor_nexthop_self_cmd);
  8724. install_element (BGP_ENCAPV6_NODE, &neighbor_nexthop_self_cmd);
  8725. install_element (BGP_ENCAPV6_NODE, &no_neighbor_nexthop_self_cmd);
  8726. /* "neighbor remove-private-AS" commands. */
  8727. install_element (BGP_NODE, &neighbor_remove_private_as_cmd);
  8728. install_element (BGP_NODE, &no_neighbor_remove_private_as_cmd);
  8729. install_element (BGP_IPV4_NODE, &neighbor_remove_private_as_cmd);
  8730. install_element (BGP_IPV4_NODE, &no_neighbor_remove_private_as_cmd);
  8731. install_element (BGP_IPV4M_NODE, &neighbor_remove_private_as_cmd);
  8732. install_element (BGP_IPV4M_NODE, &no_neighbor_remove_private_as_cmd);
  8733. install_element (BGP_IPV6_NODE, &neighbor_remove_private_as_cmd);
  8734. install_element (BGP_IPV6_NODE, &no_neighbor_remove_private_as_cmd);
  8735. install_element (BGP_IPV6M_NODE, &neighbor_remove_private_as_cmd);
  8736. install_element (BGP_IPV6M_NODE, &no_neighbor_remove_private_as_cmd);
  8737. install_element (BGP_VPNV4_NODE, &neighbor_remove_private_as_cmd);
  8738. install_element (BGP_VPNV4_NODE, &no_neighbor_remove_private_as_cmd);
  8739. install_element (BGP_VPNV6_NODE, &neighbor_remove_private_as_cmd);
  8740. install_element (BGP_VPNV6_NODE, &no_neighbor_remove_private_as_cmd);
  8741. install_element (BGP_ENCAP_NODE, &neighbor_remove_private_as_cmd);
  8742. install_element (BGP_ENCAP_NODE, &no_neighbor_remove_private_as_cmd);
  8743. install_element (BGP_ENCAPV6_NODE, &neighbor_remove_private_as_cmd);
  8744. install_element (BGP_ENCAPV6_NODE, &no_neighbor_remove_private_as_cmd);
  8745. /* "neighbor send-community" commands.*/
  8746. install_element (BGP_NODE, &neighbor_send_community_cmd);
  8747. install_element (BGP_NODE, &neighbor_send_community_type_cmd);
  8748. install_element (BGP_NODE, &no_neighbor_send_community_cmd);
  8749. install_element (BGP_NODE, &no_neighbor_send_community_type_cmd);
  8750. install_element (BGP_IPV4_NODE, &neighbor_send_community_cmd);
  8751. install_element (BGP_IPV4_NODE, &neighbor_send_community_type_cmd);
  8752. install_element (BGP_IPV4_NODE, &no_neighbor_send_community_cmd);
  8753. install_element (BGP_IPV4_NODE, &no_neighbor_send_community_type_cmd);
  8754. install_element (BGP_IPV4M_NODE, &neighbor_send_community_cmd);
  8755. install_element (BGP_IPV4M_NODE, &neighbor_send_community_type_cmd);
  8756. install_element (BGP_IPV4M_NODE, &no_neighbor_send_community_cmd);
  8757. install_element (BGP_IPV4M_NODE, &no_neighbor_send_community_type_cmd);
  8758. install_element (BGP_IPV6_NODE, &neighbor_send_community_cmd);
  8759. install_element (BGP_IPV6_NODE, &neighbor_send_community_type_cmd);
  8760. install_element (BGP_IPV6_NODE, &no_neighbor_send_community_cmd);
  8761. install_element (BGP_IPV6_NODE, &no_neighbor_send_community_type_cmd);
  8762. install_element (BGP_IPV6M_NODE, &neighbor_send_community_cmd);
  8763. install_element (BGP_IPV6M_NODE, &neighbor_send_community_type_cmd);
  8764. install_element (BGP_IPV6M_NODE, &no_neighbor_send_community_cmd);
  8765. install_element (BGP_IPV6M_NODE, &no_neighbor_send_community_type_cmd);
  8766. install_element (BGP_VPNV4_NODE, &neighbor_send_community_cmd);
  8767. install_element (BGP_VPNV4_NODE, &neighbor_send_community_type_cmd);
  8768. install_element (BGP_VPNV4_NODE, &no_neighbor_send_community_cmd);
  8769. install_element (BGP_VPNV4_NODE, &no_neighbor_send_community_type_cmd);
  8770. install_element (BGP_VPNV6_NODE, &neighbor_send_community_cmd);
  8771. install_element (BGP_VPNV6_NODE, &neighbor_send_community_type_cmd);
  8772. install_element (BGP_VPNV6_NODE, &no_neighbor_send_community_cmd);
  8773. install_element (BGP_VPNV6_NODE, &no_neighbor_send_community_type_cmd);
  8774. install_element (BGP_ENCAP_NODE, &neighbor_send_community_cmd);
  8775. install_element (BGP_ENCAP_NODE, &neighbor_send_community_type_cmd);
  8776. install_element (BGP_ENCAP_NODE, &no_neighbor_send_community_cmd);
  8777. install_element (BGP_ENCAP_NODE, &no_neighbor_send_community_type_cmd);
  8778. install_element (BGP_ENCAPV6_NODE, &neighbor_send_community_cmd);
  8779. install_element (BGP_ENCAPV6_NODE, &neighbor_send_community_type_cmd);
  8780. install_element (BGP_ENCAPV6_NODE, &no_neighbor_send_community_cmd);
  8781. install_element (BGP_ENCAPV6_NODE, &no_neighbor_send_community_type_cmd);
  8782. /* "neighbor route-reflector" commands.*/
  8783. install_element (BGP_NODE, &neighbor_route_reflector_client_cmd);
  8784. install_element (BGP_NODE, &no_neighbor_route_reflector_client_cmd);
  8785. install_element (BGP_IPV4_NODE, &neighbor_route_reflector_client_cmd);
  8786. install_element (BGP_IPV4_NODE, &no_neighbor_route_reflector_client_cmd);
  8787. install_element (BGP_IPV4M_NODE, &neighbor_route_reflector_client_cmd);
  8788. install_element (BGP_IPV4M_NODE, &no_neighbor_route_reflector_client_cmd);
  8789. install_element (BGP_IPV6_NODE, &neighbor_route_reflector_client_cmd);
  8790. install_element (BGP_IPV6_NODE, &no_neighbor_route_reflector_client_cmd);
  8791. install_element (BGP_IPV6M_NODE, &neighbor_route_reflector_client_cmd);
  8792. install_element (BGP_IPV6M_NODE, &no_neighbor_route_reflector_client_cmd);
  8793. install_element (BGP_VPNV4_NODE, &neighbor_route_reflector_client_cmd);
  8794. install_element (BGP_VPNV4_NODE, &no_neighbor_route_reflector_client_cmd);
  8795. install_element (BGP_VPNV6_NODE, &neighbor_route_reflector_client_cmd);
  8796. install_element (BGP_VPNV6_NODE, &no_neighbor_route_reflector_client_cmd);
  8797. install_element (BGP_ENCAP_NODE, &neighbor_route_reflector_client_cmd);
  8798. install_element (BGP_ENCAP_NODE, &no_neighbor_route_reflector_client_cmd);
  8799. install_element (BGP_ENCAPV6_NODE, &neighbor_route_reflector_client_cmd);
  8800. install_element (BGP_ENCAPV6_NODE, &no_neighbor_route_reflector_client_cmd);
  8801. /* "neighbor route-server" commands.*/
  8802. install_element (BGP_NODE, &neighbor_route_server_client_cmd);
  8803. install_element (BGP_NODE, &no_neighbor_route_server_client_cmd);
  8804. install_element (BGP_IPV4_NODE, &neighbor_route_server_client_cmd);
  8805. install_element (BGP_IPV4_NODE, &no_neighbor_route_server_client_cmd);
  8806. install_element (BGP_IPV4M_NODE, &neighbor_route_server_client_cmd);
  8807. install_element (BGP_IPV4M_NODE, &no_neighbor_route_server_client_cmd);
  8808. install_element (BGP_IPV6_NODE, &neighbor_route_server_client_cmd);
  8809. install_element (BGP_IPV6_NODE, &no_neighbor_route_server_client_cmd);
  8810. install_element (BGP_IPV6M_NODE, &neighbor_route_server_client_cmd);
  8811. install_element (BGP_IPV6M_NODE, &no_neighbor_route_server_client_cmd);
  8812. install_element (BGP_VPNV4_NODE, &neighbor_route_server_client_cmd);
  8813. install_element (BGP_VPNV4_NODE, &no_neighbor_route_server_client_cmd);
  8814. install_element (BGP_VPNV6_NODE, &neighbor_route_server_client_cmd);
  8815. install_element (BGP_VPNV6_NODE, &no_neighbor_route_server_client_cmd);
  8816. install_element (BGP_ENCAP_NODE, &neighbor_route_server_client_cmd);
  8817. install_element (BGP_ENCAP_NODE, &no_neighbor_route_server_client_cmd);
  8818. install_element (BGP_ENCAPV6_NODE, &neighbor_route_server_client_cmd);
  8819. install_element (BGP_ENCAPV6_NODE, &no_neighbor_route_server_client_cmd);
  8820. /* "neighbor passive" commands. */
  8821. install_element (BGP_NODE, &neighbor_passive_cmd);
  8822. install_element (BGP_NODE, &no_neighbor_passive_cmd);
  8823. /* "neighbor shutdown" commands. */
  8824. install_element (BGP_NODE, &neighbor_shutdown_cmd);
  8825. install_element (BGP_NODE, &no_neighbor_shutdown_cmd);
  8826. /* Deprecated "neighbor capability route-refresh" commands.*/
  8827. install_element (BGP_NODE, &neighbor_capability_route_refresh_cmd);
  8828. install_element (BGP_NODE, &no_neighbor_capability_route_refresh_cmd);
  8829. /* "neighbor capability orf prefix-list" commands.*/
  8830. install_element (BGP_NODE, &neighbor_capability_orf_prefix_cmd);
  8831. install_element (BGP_NODE, &no_neighbor_capability_orf_prefix_cmd);
  8832. install_element (BGP_IPV4_NODE, &neighbor_capability_orf_prefix_cmd);
  8833. install_element (BGP_IPV4_NODE, &no_neighbor_capability_orf_prefix_cmd);
  8834. install_element (BGP_IPV4M_NODE, &neighbor_capability_orf_prefix_cmd);
  8835. install_element (BGP_IPV4M_NODE, &no_neighbor_capability_orf_prefix_cmd);
  8836. install_element (BGP_IPV6_NODE, &neighbor_capability_orf_prefix_cmd);
  8837. install_element (BGP_IPV6_NODE, &no_neighbor_capability_orf_prefix_cmd);
  8838. install_element (BGP_IPV6M_NODE, &neighbor_capability_orf_prefix_cmd);
  8839. install_element (BGP_IPV6M_NODE, &no_neighbor_capability_orf_prefix_cmd);
  8840. /* "neighbor capability dynamic" commands.*/
  8841. install_element (BGP_NODE, &neighbor_capability_dynamic_cmd);
  8842. install_element (BGP_NODE, &no_neighbor_capability_dynamic_cmd);
  8843. /* "neighbor dont-capability-negotiate" commands. */
  8844. install_element (BGP_NODE, &neighbor_dont_capability_negotiate_cmd);
  8845. install_element (BGP_NODE, &no_neighbor_dont_capability_negotiate_cmd);
  8846. /* "neighbor ebgp-multihop" commands. */
  8847. install_element (BGP_NODE, &neighbor_ebgp_multihop_cmd);
  8848. install_element (BGP_NODE, &neighbor_ebgp_multihop_ttl_cmd);
  8849. install_element (BGP_NODE, &no_neighbor_ebgp_multihop_cmd);
  8850. install_element (BGP_NODE, &no_neighbor_ebgp_multihop_ttl_cmd);
  8851. /* "neighbor disable-connected-check" commands. */
  8852. install_element (BGP_NODE, &neighbor_disable_connected_check_cmd);
  8853. install_element (BGP_NODE, &no_neighbor_disable_connected_check_cmd);
  8854. install_element (BGP_NODE, &neighbor_enforce_multihop_cmd);
  8855. install_element (BGP_NODE, &no_neighbor_enforce_multihop_cmd);
  8856. /* "neighbor description" commands. */
  8857. install_element (BGP_NODE, &neighbor_description_cmd);
  8858. install_element (BGP_NODE, &no_neighbor_description_cmd);
  8859. install_element (BGP_NODE, &no_neighbor_description_val_cmd);
  8860. /* "neighbor update-source" commands. "*/
  8861. install_element (BGP_NODE, &neighbor_update_source_cmd);
  8862. install_element (BGP_NODE, &no_neighbor_update_source_cmd);
  8863. /* "neighbor default-originate" commands. */
  8864. install_element (BGP_NODE, &neighbor_default_originate_cmd);
  8865. install_element (BGP_NODE, &neighbor_default_originate_rmap_cmd);
  8866. install_element (BGP_NODE, &no_neighbor_default_originate_cmd);
  8867. install_element (BGP_NODE, &no_neighbor_default_originate_rmap_cmd);
  8868. install_element (BGP_IPV4_NODE, &neighbor_default_originate_cmd);
  8869. install_element (BGP_IPV4_NODE, &neighbor_default_originate_rmap_cmd);
  8870. install_element (BGP_IPV4_NODE, &no_neighbor_default_originate_cmd);
  8871. install_element (BGP_IPV4_NODE, &no_neighbor_default_originate_rmap_cmd);
  8872. install_element (BGP_IPV4M_NODE, &neighbor_default_originate_cmd);
  8873. install_element (BGP_IPV4M_NODE, &neighbor_default_originate_rmap_cmd);
  8874. install_element (BGP_IPV4M_NODE, &no_neighbor_default_originate_cmd);
  8875. install_element (BGP_IPV4M_NODE, &no_neighbor_default_originate