bgp_vty.c 398 KB

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