bgp_vty.c 345 KB

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