bgp_vty.c 383 KB

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