bgp_vty.c 344 KB

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