bgp_vty.c 382 KB

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