pim_cmd.c 108 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077
  1. /*
  2. PIM for Quagga
  3. Copyright (C) 2008 Everton da Silva Marques
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  8. This program 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 this program; see the file COPYING; if not, write to the
  14. Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
  15. MA 02110-1301 USA
  16. $QuaggaId: $Format:%an, %ai, %h$ $
  17. */
  18. #include <sys/ioctl.h>
  19. #include <zebra.h>
  20. #include "command.h"
  21. #include "if.h"
  22. #include "prefix.h"
  23. #include "pimd.h"
  24. #include "pim_cmd.h"
  25. #include "pim_iface.h"
  26. #include "pim_vty.h"
  27. #include "pim_mroute.h"
  28. #include "pim_str.h"
  29. #include "pim_igmpv3.h"
  30. #include "pim_sock.h"
  31. #include "pim_time.h"
  32. #include "pim_util.h"
  33. #include "pim_oil.h"
  34. #include "pim_neighbor.h"
  35. #include "pim_pim.h"
  36. #include "pim_ifchannel.h"
  37. #include "pim_hello.h"
  38. #include "pim_msg.h"
  39. #include "pim_upstream.h"
  40. #include "pim_rpf.h"
  41. #include "pim_macro.h"
  42. #include "pim_ssmpingd.h"
  43. static struct cmd_node pim_global_node = {
  44. PIM_NODE,
  45. "",
  46. 1 /* vtysh ? yes */
  47. };
  48. static struct cmd_node interface_node = {
  49. INTERFACE_NODE,
  50. "%s(config-if)# ",
  51. 1 /* vtysh ? yes */
  52. };
  53. static void pim_if_membership_clear(struct interface *ifp)
  54. {
  55. struct pim_interface *pim_ifp;
  56. pim_ifp = ifp->info;
  57. zassert(pim_ifp);
  58. if (PIM_IF_TEST_PIM(pim_ifp->options) &&
  59. PIM_IF_TEST_IGMP(pim_ifp->options)) {
  60. return;
  61. }
  62. pim_ifchannel_membership_clear(ifp);
  63. }
  64. /*
  65. When PIM is disabled on interface, IGMPv3 local membership
  66. information is not injected into PIM interface state.
  67. The function pim_if_membership_refresh() fetches all IGMPv3 local
  68. membership information into PIM. It is intented to be called
  69. whenever PIM is enabled on the interface in order to collect missed
  70. local membership information.
  71. */
  72. static void pim_if_membership_refresh(struct interface *ifp)
  73. {
  74. struct pim_interface *pim_ifp;
  75. struct listnode *sock_node;
  76. struct igmp_sock *igmp;
  77. pim_ifp = ifp->info;
  78. zassert(pim_ifp);
  79. if (!PIM_IF_TEST_PIM(pim_ifp->options))
  80. return;
  81. if (!PIM_IF_TEST_IGMP(pim_ifp->options))
  82. return;
  83. /*
  84. First clear off membership from all PIM (S,G) entries on the
  85. interface
  86. */
  87. pim_ifchannel_membership_clear(ifp);
  88. /*
  89. Then restore PIM (S,G) membership from all IGMPv3 (S,G) entries on
  90. the interface
  91. */
  92. /* scan igmp sockets */
  93. for (ALL_LIST_ELEMENTS_RO(pim_ifp->igmp_socket_list, sock_node, igmp)) {
  94. struct listnode *grpnode;
  95. struct igmp_group *grp;
  96. /* scan igmp groups */
  97. for (ALL_LIST_ELEMENTS_RO(igmp->igmp_group_list, grpnode, grp)) {
  98. struct listnode *srcnode;
  99. struct igmp_source *src;
  100. /* scan group sources */
  101. for (ALL_LIST_ELEMENTS_RO(grp->group_source_list, srcnode, src)) {
  102. if (IGMP_SOURCE_TEST_FORWARDING(src->source_flags)) {
  103. pim_ifchannel_local_membership_add(ifp,
  104. src->source_addr,
  105. grp->group_addr);
  106. }
  107. } /* scan group sources */
  108. } /* scan igmp groups */
  109. } /* scan igmp sockets */
  110. /*
  111. Finally delete every PIM (S,G) entry lacking all state info
  112. */
  113. pim_ifchannel_delete_on_noinfo(ifp);
  114. }
  115. static void pim_show_assert(struct vty *vty)
  116. {
  117. struct listnode *ifnode;
  118. struct interface *ifp;
  119. time_t now;
  120. now = pim_time_monotonic_sec();
  121. vty_out(vty,
  122. "Interface Address Source Group State Winner Uptime Timer%s",
  123. VTY_NEWLINE);
  124. for (ALL_LIST_ELEMENTS_RO(iflist, ifnode, ifp)) {
  125. struct pim_interface *pim_ifp;
  126. struct in_addr ifaddr;
  127. struct listnode *ch_node;
  128. struct pim_ifchannel *ch;
  129. pim_ifp = ifp->info;
  130. if (!pim_ifp)
  131. continue;
  132. ifaddr = pim_ifp->primary_address;
  133. for (ALL_LIST_ELEMENTS_RO(pim_ifp->pim_ifchannel_list, ch_node, ch)) {
  134. char ch_src_str[100];
  135. char ch_grp_str[100];
  136. char winner_str[100];
  137. char uptime[10];
  138. char timer[10];
  139. pim_inet4_dump("<ch_src?>", ch->source_addr,
  140. ch_src_str, sizeof(ch_src_str));
  141. pim_inet4_dump("<ch_grp?>", ch->group_addr,
  142. ch_grp_str, sizeof(ch_grp_str));
  143. pim_inet4_dump("<assrt_win?>", ch->ifassert_winner,
  144. winner_str, sizeof(winner_str));
  145. pim_time_uptime(uptime, sizeof(uptime), now - ch->ifassert_creation);
  146. pim_time_timer_to_mmss(timer, sizeof(timer),
  147. ch->t_ifassert_timer);
  148. vty_out(vty, "%-9s %-15s %-15s %-15s %-6s %-15s %-8s %-5s%s",
  149. ifp->name,
  150. inet_ntoa(ifaddr),
  151. ch_src_str,
  152. ch_grp_str,
  153. pim_ifchannel_ifassert_name(ch->ifassert_state),
  154. winner_str,
  155. uptime,
  156. timer,
  157. VTY_NEWLINE);
  158. } /* scan interface channels */
  159. } /* scan interfaces */
  160. }
  161. static void pim_show_assert_internal(struct vty *vty)
  162. {
  163. struct listnode *ifnode;
  164. struct interface *ifp;
  165. vty_out(vty,
  166. "CA: CouldAssert%s"
  167. "ECA: Evaluate CouldAssert%s"
  168. "ATD: AssertTrackingDesired%s"
  169. "eATD: Evaluate AssertTrackingDesired%s%s",
  170. VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE);
  171. vty_out(vty,
  172. "Interface Address Source Group CA eCA ATD eATD%s",
  173. VTY_NEWLINE);
  174. for (ALL_LIST_ELEMENTS_RO(iflist, ifnode, ifp)) {
  175. struct pim_interface *pim_ifp;
  176. struct in_addr ifaddr;
  177. struct listnode *ch_node;
  178. struct pim_ifchannel *ch;
  179. pim_ifp = ifp->info;
  180. if (!pim_ifp)
  181. continue;
  182. ifaddr = pim_ifp->primary_address;
  183. for (ALL_LIST_ELEMENTS_RO(pim_ifp->pim_ifchannel_list, ch_node, ch)) {
  184. char ch_src_str[100];
  185. char ch_grp_str[100];
  186. pim_inet4_dump("<ch_src?>", ch->source_addr,
  187. ch_src_str, sizeof(ch_src_str));
  188. pim_inet4_dump("<ch_grp?>", ch->group_addr,
  189. ch_grp_str, sizeof(ch_grp_str));
  190. vty_out(vty, "%-9s %-15s %-15s %-15s %-3s %-3s %-3s %-4s%s",
  191. ifp->name,
  192. inet_ntoa(ifaddr),
  193. ch_src_str,
  194. ch_grp_str,
  195. PIM_IF_FLAG_TEST_COULD_ASSERT(ch->flags) ? "yes" : "no",
  196. pim_macro_ch_could_assert_eval(ch) ? "yes" : "no",
  197. PIM_IF_FLAG_TEST_ASSERT_TRACKING_DESIRED(ch->flags) ? "yes" : "no",
  198. pim_macro_assert_tracking_desired_eval(ch) ? "yes" : "no",
  199. VTY_NEWLINE);
  200. } /* scan interface channels */
  201. } /* scan interfaces */
  202. }
  203. static void pim_show_assert_metric(struct vty *vty)
  204. {
  205. struct listnode *ifnode;
  206. struct interface *ifp;
  207. vty_out(vty,
  208. "Interface Address Source Group RPT Pref Metric Address %s",
  209. VTY_NEWLINE);
  210. for (ALL_LIST_ELEMENTS_RO(iflist, ifnode, ifp)) {
  211. struct pim_interface *pim_ifp;
  212. struct in_addr ifaddr;
  213. struct listnode *ch_node;
  214. struct pim_ifchannel *ch;
  215. pim_ifp = ifp->info;
  216. if (!pim_ifp)
  217. continue;
  218. ifaddr = pim_ifp->primary_address;
  219. for (ALL_LIST_ELEMENTS_RO(pim_ifp->pim_ifchannel_list, ch_node, ch)) {
  220. char ch_src_str[100];
  221. char ch_grp_str[100];
  222. char addr_str[100];
  223. struct pim_assert_metric am;
  224. am = pim_macro_spt_assert_metric(&ch->upstream->rpf, pim_ifp->primary_address);
  225. pim_inet4_dump("<ch_src?>", ch->source_addr,
  226. ch_src_str, sizeof(ch_src_str));
  227. pim_inet4_dump("<ch_grp?>", ch->group_addr,
  228. ch_grp_str, sizeof(ch_grp_str));
  229. pim_inet4_dump("<addr?>", am.ip_address,
  230. addr_str, sizeof(addr_str));
  231. vty_out(vty, "%-9s %-15s %-15s %-15s %-3s %4u %6u %-15s%s",
  232. ifp->name,
  233. inet_ntoa(ifaddr),
  234. ch_src_str,
  235. ch_grp_str,
  236. am.rpt_bit_flag ? "yes" : "no",
  237. am.metric_preference,
  238. am.route_metric,
  239. addr_str,
  240. VTY_NEWLINE);
  241. } /* scan interface channels */
  242. } /* scan interfaces */
  243. }
  244. static void pim_show_assert_winner_metric(struct vty *vty)
  245. {
  246. struct listnode *ifnode;
  247. struct interface *ifp;
  248. vty_out(vty,
  249. "Interface Address Source Group RPT Pref Metric Address %s",
  250. VTY_NEWLINE);
  251. for (ALL_LIST_ELEMENTS_RO(iflist, ifnode, ifp)) {
  252. struct pim_interface *pim_ifp;
  253. struct in_addr ifaddr;
  254. struct listnode *ch_node;
  255. struct pim_ifchannel *ch;
  256. pim_ifp = ifp->info;
  257. if (!pim_ifp)
  258. continue;
  259. ifaddr = pim_ifp->primary_address;
  260. for (ALL_LIST_ELEMENTS_RO(pim_ifp->pim_ifchannel_list, ch_node, ch)) {
  261. char ch_src_str[100];
  262. char ch_grp_str[100];
  263. char addr_str[100];
  264. struct pim_assert_metric *am;
  265. char pref_str[5];
  266. char metr_str[7];
  267. am = &ch->ifassert_winner_metric;
  268. pim_inet4_dump("<ch_src?>", ch->source_addr,
  269. ch_src_str, sizeof(ch_src_str));
  270. pim_inet4_dump("<ch_grp?>", ch->group_addr,
  271. ch_grp_str, sizeof(ch_grp_str));
  272. pim_inet4_dump("<addr?>", am->ip_address,
  273. addr_str, sizeof(addr_str));
  274. if (am->metric_preference == PIM_ASSERT_METRIC_PREFERENCE_MAX)
  275. snprintf(pref_str, sizeof(pref_str), "INFI");
  276. else
  277. snprintf(pref_str, sizeof(pref_str), "%4u", am->metric_preference);
  278. if (am->route_metric == PIM_ASSERT_ROUTE_METRIC_MAX)
  279. snprintf(metr_str, sizeof(metr_str), "INFI");
  280. else
  281. snprintf(metr_str, sizeof(metr_str), "%6u", am->route_metric);
  282. vty_out(vty, "%-9s %-15s %-15s %-15s %-3s %-4s %-6s %-15s%s",
  283. ifp->name,
  284. inet_ntoa(ifaddr),
  285. ch_src_str,
  286. ch_grp_str,
  287. am->rpt_bit_flag ? "yes" : "no",
  288. pref_str,
  289. metr_str,
  290. addr_str,
  291. VTY_NEWLINE);
  292. } /* scan interface channels */
  293. } /* scan interfaces */
  294. }
  295. static void pim_show_membership(struct vty *vty)
  296. {
  297. struct listnode *ifnode;
  298. struct interface *ifp;
  299. vty_out(vty,
  300. "Interface Address Source Group Membership%s",
  301. VTY_NEWLINE);
  302. for (ALL_LIST_ELEMENTS_RO(iflist, ifnode, ifp)) {
  303. struct pim_interface *pim_ifp;
  304. struct in_addr ifaddr;
  305. struct listnode *ch_node;
  306. struct pim_ifchannel *ch;
  307. pim_ifp = ifp->info;
  308. if (!pim_ifp)
  309. continue;
  310. ifaddr = pim_ifp->primary_address;
  311. for (ALL_LIST_ELEMENTS_RO(pim_ifp->pim_ifchannel_list, ch_node, ch)) {
  312. char ch_src_str[100];
  313. char ch_grp_str[100];
  314. pim_inet4_dump("<ch_src?>", ch->source_addr,
  315. ch_src_str, sizeof(ch_src_str));
  316. pim_inet4_dump("<ch_grp?>", ch->group_addr,
  317. ch_grp_str, sizeof(ch_grp_str));
  318. vty_out(vty, "%-9s %-15s %-15s %-15s %-10s%s",
  319. ifp->name,
  320. inet_ntoa(ifaddr),
  321. ch_src_str,
  322. ch_grp_str,
  323. ch->local_ifmembership == PIM_IFMEMBERSHIP_NOINFO ?
  324. "NOINFO" : "INCLUDE",
  325. VTY_NEWLINE);
  326. } /* scan interface channels */
  327. } /* scan interfaces */
  328. }
  329. static void igmp_show_interfaces(struct vty *vty)
  330. {
  331. struct listnode *node;
  332. struct interface *ifp;
  333. time_t now;
  334. now = pim_time_monotonic_sec();
  335. vty_out(vty,
  336. "Interface Address ifIndex Socket Uptime Multi Broad MLoop AllMu Prmsc Del%s",
  337. VTY_NEWLINE);
  338. for (ALL_LIST_ELEMENTS_RO(iflist, node, ifp)) {
  339. struct pim_interface *pim_ifp;
  340. struct listnode *sock_node;
  341. struct igmp_sock *igmp;
  342. pim_ifp = ifp->info;
  343. if (!pim_ifp)
  344. continue;
  345. for (ALL_LIST_ELEMENTS_RO(pim_ifp->igmp_socket_list, sock_node, igmp)) {
  346. char uptime[10];
  347. int mloop;
  348. pim_time_uptime(uptime, sizeof(uptime), now - igmp->sock_creation);
  349. mloop = pim_socket_mcastloop_get(igmp->fd);
  350. vty_out(vty, "%-9s %-15s %7d %6d %8s %5s %5s %5s %5s %5s %3s%s",
  351. ifp->name,
  352. inet_ntoa(igmp->ifaddr),
  353. ifp->ifindex,
  354. igmp->fd,
  355. uptime,
  356. if_is_multicast(ifp) ? "yes" : "no",
  357. if_is_broadcast(ifp) ? "yes" : "no",
  358. (mloop < 0) ? "?" : (mloop ? "yes" : "no"),
  359. (ifp->flags & IFF_ALLMULTI) ? "yes" : "no",
  360. (ifp->flags & IFF_PROMISC) ? "yes" : "no",
  361. PIM_IF_IS_DELETED(ifp) ? "yes" : "no",
  362. VTY_NEWLINE);
  363. }
  364. }
  365. }
  366. static void show_interface_address(struct vty *vty)
  367. {
  368. struct listnode *ifpnode;
  369. struct interface *ifp;
  370. vty_out(vty,
  371. "Interface Primary Secondary %s",
  372. VTY_NEWLINE);
  373. for (ALL_LIST_ELEMENTS_RO(iflist, ifpnode, ifp)) {
  374. struct listnode *ifcnode;
  375. struct connected *ifc;
  376. struct in_addr pri_addr;
  377. char pri_addr_str[100];
  378. pri_addr = pim_find_primary_addr(ifp);
  379. pim_inet4_dump("<pri?>", pri_addr, pri_addr_str, sizeof(pri_addr_str));
  380. for (ALL_LIST_ELEMENTS_RO(ifp->connected, ifcnode, ifc)) {
  381. char sec_addr_str[100];
  382. struct prefix *p = ifc->address;
  383. if (p->family != AF_INET)
  384. continue;
  385. if (p->u.prefix4.s_addr == pri_addr.s_addr) {
  386. sec_addr_str[0] = '\0';
  387. }
  388. else {
  389. pim_inet4_dump("<sec?>", p->u.prefix4, sec_addr_str, sizeof(sec_addr_str));
  390. }
  391. vty_out(vty, "%-9s %-15s %-15s%s",
  392. ifp->name,
  393. pri_addr_str,
  394. sec_addr_str,
  395. VTY_NEWLINE);
  396. }
  397. }
  398. }
  399. static void pim_show_dr(struct vty *vty)
  400. {
  401. struct listnode *node;
  402. struct interface *ifp;
  403. time_t now;
  404. now = pim_time_monotonic_sec();
  405. vty_out(vty,
  406. "NonPri: Number of neighbors missing DR Priority hello option%s%s",
  407. VTY_NEWLINE, VTY_NEWLINE);
  408. vty_out(vty, "Interface Address DR Uptime Elections NonPri%s", VTY_NEWLINE);
  409. for (ALL_LIST_ELEMENTS_RO(iflist, node, ifp)) {
  410. struct pim_interface *pim_ifp;
  411. struct in_addr ifaddr;
  412. char dr_str[100];
  413. char dr_uptime[10];
  414. pim_ifp = ifp->info;
  415. if (!pim_ifp)
  416. continue;
  417. if (pim_ifp->pim_sock_fd < 0)
  418. continue;
  419. ifaddr = pim_ifp->primary_address;
  420. pim_time_uptime(dr_uptime, sizeof(dr_uptime),
  421. now - pim_ifp->pim_dr_election_last);
  422. pim_inet4_dump("<dr?>", pim_ifp->pim_dr_addr,
  423. dr_str, sizeof(dr_str));
  424. vty_out(vty, "%-9s %-15s %-15s %8s %9d %6d%s",
  425. ifp->name,
  426. inet_ntoa(ifaddr),
  427. dr_str,
  428. dr_uptime,
  429. pim_ifp->pim_dr_election_count,
  430. pim_ifp->pim_dr_num_nondrpri_neighbors,
  431. VTY_NEWLINE);
  432. }
  433. }
  434. static void pim_show_hello(struct vty *vty)
  435. {
  436. struct listnode *node;
  437. struct interface *ifp;
  438. time_t now;
  439. now = pim_time_monotonic_sec();
  440. vty_out(vty, "Interface Address Period Timer StatStart Recv Rfail Send Sfail%s", VTY_NEWLINE);
  441. for (ALL_LIST_ELEMENTS_RO(iflist, node, ifp)) {
  442. struct pim_interface *pim_ifp;
  443. struct in_addr ifaddr;
  444. char hello_period[10];
  445. char hello_timer[10];
  446. char stat_uptime[10];
  447. pim_ifp = ifp->info;
  448. if (!pim_ifp)
  449. continue;
  450. if (pim_ifp->pim_sock_fd < 0)
  451. continue;
  452. ifaddr = pim_ifp->primary_address;
  453. pim_time_timer_to_mmss(hello_timer, sizeof(hello_timer), pim_ifp->t_pim_hello_timer);
  454. pim_time_mmss(hello_period, sizeof(hello_period), pim_ifp->pim_hello_period);
  455. pim_time_uptime(stat_uptime, sizeof(stat_uptime), now - pim_ifp->pim_ifstat_start);
  456. vty_out(vty, "%-9s %-15s %6s %5s %9s %4u %5u %4u %5u%s",
  457. ifp->name,
  458. inet_ntoa(ifaddr),
  459. hello_period,
  460. hello_timer,
  461. stat_uptime,
  462. pim_ifp->pim_ifstat_hello_recv,
  463. pim_ifp->pim_ifstat_hello_recvfail,
  464. pim_ifp->pim_ifstat_hello_sent,
  465. pim_ifp->pim_ifstat_hello_sendfail,
  466. VTY_NEWLINE);
  467. }
  468. }
  469. static void pim_show_interfaces(struct vty *vty)
  470. {
  471. struct listnode *node;
  472. struct interface *ifp;
  473. time_t now;
  474. now = pim_time_monotonic_sec();
  475. vty_out(vty, "Interface Address ifIndex Socket Uptime Multi Broad MLoop AllMu Prmsc Del%s", VTY_NEWLINE);
  476. for (ALL_LIST_ELEMENTS_RO(iflist, node, ifp)) {
  477. struct pim_interface *pim_ifp;
  478. struct in_addr ifaddr;
  479. char uptime[10];
  480. int mloop;
  481. pim_ifp = ifp->info;
  482. if (!pim_ifp)
  483. continue;
  484. if (pim_ifp->pim_sock_fd < 0)
  485. continue;
  486. ifaddr = pim_ifp->primary_address;
  487. pim_time_uptime(uptime, sizeof(uptime), now - pim_ifp->pim_sock_creation);
  488. mloop = pim_socket_mcastloop_get(pim_ifp->pim_sock_fd);
  489. vty_out(vty, "%-9s %-15s %7d %6d %8s %5s %5s %5s %5s %5s %3s%s",
  490. ifp->name,
  491. inet_ntoa(ifaddr),
  492. ifp->ifindex,
  493. pim_ifp->pim_sock_fd,
  494. uptime,
  495. if_is_multicast(ifp) ? "yes" : "no",
  496. if_is_broadcast(ifp) ? "yes" : "no",
  497. (mloop < 0) ? "?" : (mloop ? "yes" : "no"),
  498. (ifp->flags & IFF_ALLMULTI) ? "yes" : "no",
  499. (ifp->flags & IFF_PROMISC) ? "yes" : "no",
  500. PIM_IF_IS_DELETED(ifp) ? "yes" : "no",
  501. VTY_NEWLINE);
  502. }
  503. }
  504. static void pim_show_join(struct vty *vty)
  505. {
  506. struct listnode *ifnode;
  507. struct interface *ifp;
  508. time_t now;
  509. now = pim_time_monotonic_sec();
  510. vty_out(vty,
  511. "Interface Address Source Group State Uptime Expire Prune%s",
  512. VTY_NEWLINE);
  513. for (ALL_LIST_ELEMENTS_RO(iflist, ifnode, ifp)) {
  514. struct pim_interface *pim_ifp;
  515. struct in_addr ifaddr;
  516. struct listnode *ch_node;
  517. struct pim_ifchannel *ch;
  518. pim_ifp = ifp->info;
  519. if (!pim_ifp)
  520. continue;
  521. ifaddr = pim_ifp->primary_address;
  522. for (ALL_LIST_ELEMENTS_RO(pim_ifp->pim_ifchannel_list, ch_node, ch)) {
  523. char ch_src_str[100];
  524. char ch_grp_str[100];
  525. char uptime[10];
  526. char expire[10];
  527. char prune[10];
  528. pim_inet4_dump("<ch_src?>", ch->source_addr,
  529. ch_src_str, sizeof(ch_src_str));
  530. pim_inet4_dump("<ch_grp?>", ch->group_addr,
  531. ch_grp_str, sizeof(ch_grp_str));
  532. pim_time_uptime(uptime, sizeof(uptime), now - ch->ifjoin_creation);
  533. pim_time_timer_to_mmss(expire, sizeof(expire),
  534. ch->t_ifjoin_expiry_timer);
  535. pim_time_timer_to_mmss(prune, sizeof(prune),
  536. ch->t_ifjoin_prune_pending_timer);
  537. vty_out(vty, "%-9s %-15s %-15s %-15s %-6s %8s %-6s %5s%s",
  538. ifp->name,
  539. inet_ntoa(ifaddr),
  540. ch_src_str,
  541. ch_grp_str,
  542. pim_ifchannel_ifjoin_name(ch->ifjoin_state),
  543. uptime,
  544. expire,
  545. prune,
  546. VTY_NEWLINE);
  547. } /* scan interface channels */
  548. } /* scan interfaces */
  549. }
  550. static void pim_show_neighbors(struct vty *vty)
  551. {
  552. struct listnode *node;
  553. struct interface *ifp;
  554. time_t now;
  555. now = pim_time_monotonic_sec();
  556. vty_out(vty,
  557. "Recv flags: H=holdtime L=lan_prune_delay P=dr_priority G=generation_id A=address_list%s"
  558. " T=can_disable_join_suppression%s%s",
  559. VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE);
  560. vty_out(vty, "Interface Address Neighbor Uptime Timer Holdt DrPri GenId Recv %s", VTY_NEWLINE);
  561. for (ALL_LIST_ELEMENTS_RO(iflist, node, ifp)) {
  562. struct pim_interface *pim_ifp;
  563. struct in_addr ifaddr;
  564. struct listnode *neighnode;
  565. struct pim_neighbor *neigh;
  566. pim_ifp = ifp->info;
  567. if (!pim_ifp)
  568. continue;
  569. if (pim_ifp->pim_sock_fd < 0)
  570. continue;
  571. ifaddr = pim_ifp->primary_address;
  572. for (ALL_LIST_ELEMENTS_RO(pim_ifp->pim_neighbor_list, neighnode, neigh)) {
  573. char uptime[10];
  574. char holdtime[10];
  575. char expire[10];
  576. char neigh_src_str[100];
  577. char recv[7];
  578. pim_inet4_dump("<src?>", neigh->source_addr,
  579. neigh_src_str, sizeof(neigh_src_str));
  580. pim_time_uptime(uptime, sizeof(uptime), now - neigh->creation);
  581. pim_time_mmss(holdtime, sizeof(holdtime), neigh->holdtime);
  582. pim_time_timer_to_mmss(expire, sizeof(expire), neigh->t_expire_timer);
  583. recv[0] = PIM_OPTION_IS_SET(neigh->hello_options, PIM_OPTION_MASK_HOLDTIME) ? 'H' : ' ';
  584. recv[1] = PIM_OPTION_IS_SET(neigh->hello_options, PIM_OPTION_MASK_LAN_PRUNE_DELAY) ? 'L' : ' ';
  585. recv[2] = PIM_OPTION_IS_SET(neigh->hello_options, PIM_OPTION_MASK_DR_PRIORITY) ? 'P' : ' ';
  586. recv[3] = PIM_OPTION_IS_SET(neigh->hello_options, PIM_OPTION_MASK_GENERATION_ID) ? 'G' : ' ';
  587. recv[4] = PIM_OPTION_IS_SET(neigh->hello_options, PIM_OPTION_MASK_ADDRESS_LIST) ? 'A' : ' ';
  588. recv[5] = PIM_OPTION_IS_SET(neigh->hello_options, PIM_OPTION_MASK_CAN_DISABLE_JOIN_SUPPRESSION) ? 'T' : ' ';
  589. recv[6] = '\0';
  590. vty_out(vty, "%-9s %-15s %-15s %8s %5s %5s %5u %08x %6s%s",
  591. ifp->name,
  592. inet_ntoa(ifaddr),
  593. neigh_src_str,
  594. uptime,
  595. expire,
  596. holdtime,
  597. neigh->dr_priority,
  598. neigh->generation_id,
  599. recv,
  600. VTY_NEWLINE);
  601. }
  602. }
  603. }
  604. static void pim_show_lan_prune_delay(struct vty *vty)
  605. {
  606. struct listnode *node;
  607. struct interface *ifp;
  608. vty_out(vty,
  609. "PrDly=propagation_delay (msec) OvInt=override_interval (msec)%s"
  610. "HiDly=highest_propagation_delay (msec) HiInt=highest_override_interval (msec)%s"
  611. "NoDly=number_of_non_lan_delay_neighbors%s"
  612. "T=t_bit LPD=lan_prune_delay_hello_option%s%s",
  613. VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE);
  614. vty_out(vty, "Interface Address PrDly OvInt NoDly HiDly HiInt T Neighbor LPD PrDly OvInt T%s", VTY_NEWLINE);
  615. for (ALL_LIST_ELEMENTS_RO(iflist, node, ifp)) {
  616. struct pim_interface *pim_ifp;
  617. struct in_addr ifaddr;
  618. struct listnode *neighnode;
  619. struct pim_neighbor *neigh;
  620. pim_ifp = ifp->info;
  621. if (!pim_ifp)
  622. continue;
  623. if (pim_ifp->pim_sock_fd < 0)
  624. continue;
  625. ifaddr = pim_ifp->primary_address;
  626. for (ALL_LIST_ELEMENTS_RO(pim_ifp->pim_neighbor_list, neighnode, neigh)) {
  627. char neigh_src_str[100];
  628. pim_inet4_dump("<src?>", neigh->source_addr,
  629. neigh_src_str, sizeof(neigh_src_str));
  630. vty_out(vty, "%-9s %-15s %5u %5u %5u %5u %5u %1u %-15s %-3s %5u %5u %1u%s",
  631. ifp->name,
  632. inet_ntoa(ifaddr),
  633. pim_ifp->pim_propagation_delay_msec,
  634. pim_ifp->pim_override_interval_msec,
  635. pim_ifp->pim_number_of_nonlandelay_neighbors,
  636. pim_ifp->pim_neighbors_highest_propagation_delay_msec,
  637. pim_ifp->pim_neighbors_highest_override_interval_msec,
  638. PIM_FORCE_BOOLEAN(PIM_IF_TEST_PIM_CAN_DISABLE_JOIN_SUPRESSION(pim_ifp->options)),
  639. neigh_src_str,
  640. PIM_OPTION_IS_SET(neigh->hello_options, PIM_OPTION_MASK_LAN_PRUNE_DELAY) ? "yes" : "no",
  641. neigh->propagation_delay_msec,
  642. neigh->override_interval_msec,
  643. PIM_FORCE_BOOLEAN(PIM_OPTION_IS_SET(neigh->hello_options,
  644. PIM_OPTION_MASK_CAN_DISABLE_JOIN_SUPPRESSION)),
  645. VTY_NEWLINE);
  646. }
  647. }
  648. }
  649. static void pim_show_jp_override_interval(struct vty *vty)
  650. {
  651. struct listnode *node;
  652. struct interface *ifp;
  653. vty_out(vty,
  654. "EffPDelay=effective_propagation_delay (msec)%s"
  655. "EffOvrInt=override_interval (msec)%s"
  656. "JPOvrInt=jp_override_interval (msec)%s%s",
  657. VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE);
  658. vty_out(vty, "Interface Address LAN_Delay EffPDelay EffOvrInt JPOvrInt%s", VTY_NEWLINE);
  659. for (ALL_LIST_ELEMENTS_RO(iflist, node, ifp)) {
  660. struct pim_interface *pim_ifp;
  661. struct in_addr ifaddr;
  662. pim_ifp = ifp->info;
  663. if (!pim_ifp)
  664. continue;
  665. if (pim_ifp->pim_sock_fd < 0)
  666. continue;
  667. ifaddr = pim_ifp->primary_address;
  668. vty_out(vty, "%-9s %-15s %-9s %9u %9u %8u%s",
  669. ifp->name,
  670. inet_ntoa(ifaddr),
  671. pim_if_lan_delay_enabled(ifp) ? "enabled" : "disabled",
  672. pim_if_effective_propagation_delay_msec(ifp),
  673. pim_if_effective_override_interval_msec(ifp),
  674. pim_if_jp_override_interval_msec(ifp),
  675. VTY_NEWLINE);
  676. }
  677. }
  678. static void pim_show_neighbors_secondary(struct vty *vty)
  679. {
  680. struct listnode *node;
  681. struct interface *ifp;
  682. vty_out(vty, "Interface Address Neighbor Secondary %s", VTY_NEWLINE);
  683. for (ALL_LIST_ELEMENTS_RO(iflist, node, ifp)) {
  684. struct pim_interface *pim_ifp;
  685. struct in_addr ifaddr;
  686. struct listnode *neighnode;
  687. struct pim_neighbor *neigh;
  688. pim_ifp = ifp->info;
  689. if (!pim_ifp)
  690. continue;
  691. if (pim_ifp->pim_sock_fd < 0)
  692. continue;
  693. ifaddr = pim_ifp->primary_address;
  694. for (ALL_LIST_ELEMENTS_RO(pim_ifp->pim_neighbor_list, neighnode, neigh)) {
  695. char neigh_src_str[100];
  696. struct listnode *prefix_node;
  697. struct prefix *p;
  698. if (!neigh->prefix_list)
  699. continue;
  700. pim_inet4_dump("<src?>", neigh->source_addr,
  701. neigh_src_str, sizeof(neigh_src_str));
  702. for (ALL_LIST_ELEMENTS_RO(neigh->prefix_list, prefix_node, p)) {
  703. char neigh_sec_str[100];
  704. if (p->family != AF_INET)
  705. continue;
  706. pim_inet4_dump("<src?>", p->u.prefix4,
  707. neigh_sec_str, sizeof(neigh_sec_str));
  708. vty_out(vty, "%-9s %-15s %-15s %-15s%s",
  709. ifp->name,
  710. inet_ntoa(ifaddr),
  711. neigh_src_str,
  712. neigh_sec_str,
  713. VTY_NEWLINE);
  714. }
  715. }
  716. }
  717. }
  718. static void pim_show_upstream(struct vty *vty)
  719. {
  720. struct listnode *upnode;
  721. struct pim_upstream *up;
  722. time_t now;
  723. now = pim_time_monotonic_sec();
  724. vty_out(vty, "Source Group State Uptime JoinTimer RefCnt%s", VTY_NEWLINE);
  725. for (ALL_LIST_ELEMENTS_RO(qpim_upstream_list, upnode, up)) {
  726. char src_str[100];
  727. char grp_str[100];
  728. char uptime[10];
  729. char join_timer[10];
  730. pim_inet4_dump("<src?>", up->source_addr, src_str, sizeof(src_str));
  731. pim_inet4_dump("<grp?>", up->group_addr, grp_str, sizeof(grp_str));
  732. pim_time_uptime(uptime, sizeof(uptime), now - up->state_transition);
  733. pim_time_timer_to_hhmmss(join_timer, sizeof(join_timer), up->t_join_timer);
  734. vty_out(vty, "%-15s %-15s %-5s %-8s %-9s %6d%s",
  735. src_str,
  736. grp_str,
  737. up->join_state == PIM_UPSTREAM_JOINED ? "Jnd" : "NtJnd",
  738. uptime,
  739. join_timer,
  740. up->ref_count,
  741. VTY_NEWLINE);
  742. }
  743. }
  744. static void pim_show_join_desired(struct vty *vty)
  745. {
  746. struct listnode *ifnode;
  747. struct listnode *chnode;
  748. struct interface *ifp;
  749. struct pim_interface *pim_ifp;
  750. struct pim_ifchannel *ch;
  751. struct in_addr me_ifaddr;
  752. char src_str[100];
  753. char grp_str[100];
  754. vty_out(vty,
  755. "Interface Source Group LostAssert Joins PimInclude JoinDesired EvalJD%s",
  756. VTY_NEWLINE);
  757. /* scan all interfaces */
  758. for (ALL_LIST_ELEMENTS_RO(iflist, ifnode, ifp)) {
  759. pim_ifp = ifp->info;
  760. if (!pim_ifp)
  761. continue;
  762. me_ifaddr = pim_ifp->primary_address;
  763. /* scan per-interface (S,G) state */
  764. for (ALL_LIST_ELEMENTS_RO(pim_ifp->pim_ifchannel_list, chnode, ch)) {
  765. struct pim_upstream *up = ch->upstream;
  766. pim_inet4_dump("<src?>", up->source_addr, src_str, sizeof(src_str));
  767. pim_inet4_dump("<grp?>", up->group_addr, grp_str, sizeof(grp_str));
  768. vty_out(vty, "%-9s %-15s %-15s %-10s %-5s %-10s %-11s %-6s%s",
  769. ifp->name,
  770. src_str,
  771. grp_str,
  772. pim_macro_ch_lost_assert(ch) ? "yes" : "no",
  773. pim_macro_chisin_joins(ch) ? "yes" : "no",
  774. pim_macro_chisin_pim_include(ch) ? "yes" : "no",
  775. PIM_UPSTREAM_FLAG_TEST_DR_JOIN_DESIRED(up->flags) ? "yes" : "no",
  776. pim_upstream_evaluate_join_desired(up) ? "yes" : "no",
  777. VTY_NEWLINE);
  778. }
  779. }
  780. }
  781. static void pim_show_upstream_rpf(struct vty *vty)
  782. {
  783. struct listnode *upnode;
  784. struct pim_upstream *up;
  785. vty_out(vty,
  786. "Source Group RpfIface RibNextHop RpfAddress %s",
  787. VTY_NEWLINE);
  788. for (ALL_LIST_ELEMENTS_RO(qpim_upstream_list, upnode, up)) {
  789. char src_str[100];
  790. char grp_str[100];
  791. char rpf_nexthop_str[100];
  792. char rpf_addr_str[100];
  793. struct pim_rpf *rpf;
  794. const char *rpf_ifname;
  795. rpf = &up->rpf;
  796. pim_inet4_dump("<src?>", up->source_addr, src_str, sizeof(src_str));
  797. pim_inet4_dump("<grp?>", up->group_addr, grp_str, sizeof(grp_str));
  798. pim_inet4_dump("<nexthop?>", rpf->source_nexthop.mrib_nexthop_addr, rpf_nexthop_str, sizeof(rpf_nexthop_str));
  799. pim_inet4_dump("<rpf?>", rpf->rpf_addr, rpf_addr_str, sizeof(rpf_addr_str));
  800. rpf_ifname = rpf->source_nexthop.interface ? rpf->source_nexthop.interface->name : "<ifname?>";
  801. vty_out(vty, "%-15s %-15s %-8s %-15s %-15s%s",
  802. src_str,
  803. grp_str,
  804. rpf_ifname,
  805. rpf_nexthop_str,
  806. rpf_addr_str,
  807. VTY_NEWLINE);
  808. }
  809. }
  810. static void show_rpf_refresh_stats(struct vty *vty, time_t now)
  811. {
  812. char refresh_uptime[10];
  813. pim_time_uptime(refresh_uptime, sizeof(refresh_uptime), now - qpim_rpf_cache_refresh_last);
  814. vty_out(vty,
  815. "RPF Cache Refresh Delay: %ld msecs%s"
  816. "RPF Cache Refresh Timer: %ld msecs%s"
  817. "RPF Cache Refresh Requests: %lld%s"
  818. "RPF Cache Refresh Events: %lld%s"
  819. "RPF Cache Refresh Last: %s%s",
  820. qpim_rpf_cache_refresh_delay_msec, VTY_NEWLINE,
  821. pim_time_timer_remain_msec(qpim_rpf_cache_refresher), VTY_NEWLINE,
  822. qpim_rpf_cache_refresh_requests, VTY_NEWLINE,
  823. qpim_rpf_cache_refresh_events, VTY_NEWLINE,
  824. refresh_uptime, VTY_NEWLINE);
  825. }
  826. static void pim_show_rpf(struct vty *vty)
  827. {
  828. struct listnode *up_node;
  829. struct pim_upstream *up;
  830. time_t now = pim_time_monotonic_sec();
  831. show_rpf_refresh_stats(vty, now);
  832. vty_out(vty, "%s", VTY_NEWLINE);
  833. vty_out(vty,
  834. "Source Group RpfIface RpfAddress RibNextHop Metric Pref%s",
  835. VTY_NEWLINE);
  836. for (ALL_LIST_ELEMENTS_RO(qpim_upstream_list, up_node, up)) {
  837. char src_str[100];
  838. char grp_str[100];
  839. char rpf_addr_str[100];
  840. char rib_nexthop_str[100];
  841. const char *rpf_ifname;
  842. struct pim_rpf *rpf = &up->rpf;
  843. pim_inet4_dump("<src?>", up->source_addr, src_str, sizeof(src_str));
  844. pim_inet4_dump("<grp?>", up->group_addr, grp_str, sizeof(grp_str));
  845. pim_inet4_dump("<rpf?>", rpf->rpf_addr, rpf_addr_str, sizeof(rpf_addr_str));
  846. pim_inet4_dump("<nexthop?>", rpf->source_nexthop.mrib_nexthop_addr, rib_nexthop_str, sizeof(rib_nexthop_str));
  847. rpf_ifname = rpf->source_nexthop.interface ? rpf->source_nexthop.interface->name : "<ifname?>";
  848. vty_out(vty, "%-15s %-15s %-8s %-15s %-15s %6d %4d%s",
  849. src_str,
  850. grp_str,
  851. rpf_ifname,
  852. rpf_addr_str,
  853. rib_nexthop_str,
  854. rpf->source_nexthop.mrib_route_metric,
  855. rpf->source_nexthop.mrib_metric_preference,
  856. VTY_NEWLINE);
  857. }
  858. }
  859. static void igmp_show_querier(struct vty *vty)
  860. {
  861. struct listnode *node;
  862. struct interface *ifp;
  863. vty_out(vty, "Interface Address Querier StartCount Query-Timer Other-Timer%s", VTY_NEWLINE);
  864. for (ALL_LIST_ELEMENTS_RO(iflist, node, ifp)) {
  865. struct pim_interface *pim_ifp = ifp->info;
  866. struct listnode *sock_node;
  867. struct igmp_sock *igmp;
  868. if (!pim_ifp)
  869. continue;
  870. for (ALL_LIST_ELEMENTS_RO(pim_ifp->igmp_socket_list, sock_node, igmp)) {
  871. char query_hhmmss[10];
  872. char other_hhmmss[10];
  873. pim_time_timer_to_hhmmss(query_hhmmss, sizeof(query_hhmmss), igmp->t_igmp_query_timer);
  874. pim_time_timer_to_hhmmss(other_hhmmss, sizeof(other_hhmmss), igmp->t_other_querier_timer);
  875. vty_out(vty, "%-9s %-15s %-7s %10d %11s %11s%s",
  876. ifp->name,
  877. inet_ntoa(igmp->ifaddr),
  878. igmp->t_igmp_query_timer ? "THIS" : "OTHER",
  879. igmp->startup_query_count,
  880. query_hhmmss,
  881. other_hhmmss,
  882. VTY_NEWLINE);
  883. }
  884. }
  885. }
  886. static void igmp_show_groups(struct vty *vty)
  887. {
  888. struct listnode *ifnode;
  889. struct interface *ifp;
  890. time_t now;
  891. now = pim_time_monotonic_sec();
  892. vty_out(vty, "Interface Address Group Mode Timer Srcs V Uptime %s", VTY_NEWLINE);
  893. /* scan interfaces */
  894. for (ALL_LIST_ELEMENTS_RO(iflist, ifnode, ifp)) {
  895. struct pim_interface *pim_ifp = ifp->info;
  896. struct listnode *sock_node;
  897. struct igmp_sock *igmp;
  898. if (!pim_ifp)
  899. continue;
  900. /* scan igmp sockets */
  901. for (ALL_LIST_ELEMENTS_RO(pim_ifp->igmp_socket_list, sock_node, igmp)) {
  902. char ifaddr_str[100];
  903. struct listnode *grpnode;
  904. struct igmp_group *grp;
  905. pim_inet4_dump("<ifaddr?>", igmp->ifaddr, ifaddr_str, sizeof(ifaddr_str));
  906. /* scan igmp groups */
  907. for (ALL_LIST_ELEMENTS_RO(igmp->igmp_group_list, grpnode, grp)) {
  908. char group_str[100];
  909. char hhmmss[10];
  910. char uptime[10];
  911. pim_inet4_dump("<group?>", grp->group_addr, group_str, sizeof(group_str));
  912. pim_time_timer_to_hhmmss(hhmmss, sizeof(hhmmss), grp->t_group_timer);
  913. pim_time_uptime(uptime, sizeof(uptime), now - grp->group_creation);
  914. vty_out(vty, "%-9s %-15s %-15s %4s %8s %4d %d %8s%s",
  915. ifp->name,
  916. ifaddr_str,
  917. group_str,
  918. grp->group_filtermode_isexcl ? "EXCL" : "INCL",
  919. hhmmss,
  920. grp->group_source_list ? listcount(grp->group_source_list) : 0,
  921. igmp_group_compat_mode(igmp, grp),
  922. uptime,
  923. VTY_NEWLINE);
  924. } /* scan igmp groups */
  925. } /* scan igmp sockets */
  926. } /* scan interfaces */
  927. }
  928. static void igmp_show_group_retransmission(struct vty *vty)
  929. {
  930. struct listnode *ifnode;
  931. struct interface *ifp;
  932. time_t now;
  933. now = pim_time_monotonic_sec();
  934. vty_out(vty, "Interface Address Group RetTimer Counter RetSrcs%s", VTY_NEWLINE);
  935. /* scan interfaces */
  936. for (ALL_LIST_ELEMENTS_RO(iflist, ifnode, ifp)) {
  937. struct pim_interface *pim_ifp = ifp->info;
  938. struct listnode *sock_node;
  939. struct igmp_sock *igmp;
  940. if (!pim_ifp)
  941. continue;
  942. /* scan igmp sockets */
  943. for (ALL_LIST_ELEMENTS_RO(pim_ifp->igmp_socket_list, sock_node, igmp)) {
  944. char ifaddr_str[100];
  945. struct listnode *grpnode;
  946. struct igmp_group *grp;
  947. pim_inet4_dump("<ifaddr?>", igmp->ifaddr, ifaddr_str, sizeof(ifaddr_str));
  948. /* scan igmp groups */
  949. for (ALL_LIST_ELEMENTS_RO(igmp->igmp_group_list, grpnode, grp)) {
  950. char group_str[100];
  951. char grp_retr_mmss[10];
  952. struct listnode *src_node;
  953. struct igmp_source *src;
  954. int grp_retr_sources = 0;
  955. pim_inet4_dump("<group?>", grp->group_addr, group_str, sizeof(group_str));
  956. pim_time_timer_to_mmss(grp_retr_mmss, sizeof(grp_retr_mmss), grp->t_group_query_retransmit_timer);
  957. /* count group sources with retransmission state */
  958. for (ALL_LIST_ELEMENTS_RO(grp->group_source_list, src_node, src)) {
  959. if (src->source_query_retransmit_count > 0) {
  960. ++grp_retr_sources;
  961. }
  962. }
  963. vty_out(vty, "%-9s %-15s %-15s %-8s %7d %7d%s",
  964. ifp->name,
  965. ifaddr_str,
  966. group_str,
  967. grp_retr_mmss,
  968. grp->group_specific_query_retransmit_count,
  969. grp_retr_sources,
  970. VTY_NEWLINE);
  971. } /* scan igmp groups */
  972. } /* scan igmp sockets */
  973. } /* scan interfaces */
  974. }
  975. static void igmp_show_parameters(struct vty *vty)
  976. {
  977. struct listnode *ifnode;
  978. struct interface *ifp;
  979. vty_out(vty,
  980. "QRV: Robustness Variable SQI: Startup Query Interval%s"
  981. "QQI: Query Interval OQPI: Other Querier Present Interval%s"
  982. "QRI: Query Response Interval LMQT: Last Member Query Time%s"
  983. "GMI: Group Membership Interval OHPI: Older Host Present Interval%s%s",
  984. VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE);
  985. vty_out(vty,
  986. "Interface Address QRV QQI QRI GMI SQI OQPI LMQT OHPI %s",
  987. VTY_NEWLINE);
  988. /* scan interfaces */
  989. for (ALL_LIST_ELEMENTS_RO(iflist, ifnode, ifp)) {
  990. struct pim_interface *pim_ifp = ifp->info;
  991. struct listnode *sock_node;
  992. struct igmp_sock *igmp;
  993. if (!pim_ifp)
  994. continue;
  995. /* scan igmp sockets */
  996. for (ALL_LIST_ELEMENTS_RO(pim_ifp->igmp_socket_list, sock_node, igmp)) {
  997. char ifaddr_str[100];
  998. long gmi_dsec; /* Group Membership Interval */
  999. long oqpi_dsec; /* Other Querier Present Interval */
  1000. int sqi;
  1001. long lmqt_dsec;
  1002. long ohpi_dsec;
  1003. long qri_dsec;
  1004. pim_inet4_dump("<ifaddr?>", igmp->ifaddr, ifaddr_str, sizeof(ifaddr_str));
  1005. gmi_dsec = PIM_IGMP_GMI_MSEC(igmp->querier_robustness_variable,
  1006. igmp->querier_query_interval,
  1007. pim_ifp->igmp_query_max_response_time_dsec) / 100;
  1008. sqi = PIM_IGMP_SQI(pim_ifp->igmp_default_query_interval);
  1009. oqpi_dsec = PIM_IGMP_OQPI_MSEC(igmp->querier_robustness_variable,
  1010. igmp->querier_query_interval,
  1011. pim_ifp->igmp_query_max_response_time_dsec) / 100;
  1012. lmqt_dsec = PIM_IGMP_LMQT_MSEC(pim_ifp->igmp_query_max_response_time_dsec,
  1013. igmp->querier_robustness_variable) / 100;
  1014. ohpi_dsec = PIM_IGMP_OHPI_DSEC(igmp->querier_robustness_variable,
  1015. igmp->querier_query_interval,
  1016. pim_ifp->igmp_query_max_response_time_dsec);
  1017. qri_dsec = pim_ifp->igmp_query_max_response_time_dsec;
  1018. vty_out(vty,
  1019. "%-9s %-15s %3d %3d %3ld.%ld %3ld.%ld %3d %3ld.%ld %3ld.%ld %3ld.%ld%s",
  1020. ifp->name,
  1021. ifaddr_str,
  1022. igmp->querier_robustness_variable,
  1023. igmp->querier_query_interval,
  1024. qri_dsec / 10, qri_dsec % 10,
  1025. gmi_dsec / 10, gmi_dsec % 10,
  1026. sqi,
  1027. oqpi_dsec / 10, oqpi_dsec % 10,
  1028. lmqt_dsec / 10, lmqt_dsec % 10,
  1029. ohpi_dsec / 10, ohpi_dsec % 10,
  1030. VTY_NEWLINE);
  1031. } /* scan igmp sockets */
  1032. } /* scan interfaces */
  1033. }
  1034. static void igmp_show_sources(struct vty *vty)
  1035. {
  1036. struct listnode *ifnode;
  1037. struct interface *ifp;
  1038. time_t now;
  1039. now = pim_time_monotonic_sec();
  1040. vty_out(vty, "Interface Address Group Source Timer Fwd Uptime %s", VTY_NEWLINE);
  1041. /* scan interfaces */
  1042. for (ALL_LIST_ELEMENTS_RO(iflist, ifnode, ifp)) {
  1043. struct pim_interface *pim_ifp = ifp->info;
  1044. struct listnode *sock_node;
  1045. struct igmp_sock *igmp;
  1046. if (!pim_ifp)
  1047. continue;
  1048. /* scan igmp sockets */
  1049. for (ALL_LIST_ELEMENTS_RO(pim_ifp->igmp_socket_list, sock_node, igmp)) {
  1050. char ifaddr_str[100];
  1051. struct listnode *grpnode;
  1052. struct igmp_group *grp;
  1053. pim_inet4_dump("<ifaddr?>", igmp->ifaddr, ifaddr_str, sizeof(ifaddr_str));
  1054. /* scan igmp groups */
  1055. for (ALL_LIST_ELEMENTS_RO(igmp->igmp_group_list, grpnode, grp)) {
  1056. char group_str[100];
  1057. struct listnode *srcnode;
  1058. struct igmp_source *src;
  1059. pim_inet4_dump("<group?>", grp->group_addr, group_str, sizeof(group_str));
  1060. /* scan group sources */
  1061. for (ALL_LIST_ELEMENTS_RO(grp->group_source_list, srcnode, src)) {
  1062. char source_str[100];
  1063. char mmss[10];
  1064. char uptime[10];
  1065. pim_inet4_dump("<source?>", src->source_addr, source_str, sizeof(source_str));
  1066. pim_time_timer_to_mmss(mmss, sizeof(mmss), src->t_source_timer);
  1067. pim_time_uptime(uptime, sizeof(uptime), now - src->source_creation);
  1068. vty_out(vty, "%-9s %-15s %-15s %-15s %5s %3s %8s%s",
  1069. ifp->name,
  1070. ifaddr_str,
  1071. group_str,
  1072. source_str,
  1073. mmss,
  1074. IGMP_SOURCE_TEST_FORWARDING(src->source_flags) ? "Y" : "N",
  1075. uptime,
  1076. VTY_NEWLINE);
  1077. } /* scan group sources */
  1078. } /* scan igmp groups */
  1079. } /* scan igmp sockets */
  1080. } /* scan interfaces */
  1081. }
  1082. static void igmp_show_source_retransmission(struct vty *vty)
  1083. {
  1084. struct listnode *ifnode;
  1085. struct interface *ifp;
  1086. time_t now;
  1087. now = pim_time_monotonic_sec();
  1088. vty_out(vty, "Interface Address Group Source Counter%s", VTY_NEWLINE);
  1089. /* scan interfaces */
  1090. for (ALL_LIST_ELEMENTS_RO(iflist, ifnode, ifp)) {
  1091. struct pim_interface *pim_ifp = ifp->info;
  1092. struct listnode *sock_node;
  1093. struct igmp_sock *igmp;
  1094. if (!pim_ifp)
  1095. continue;
  1096. /* scan igmp sockets */
  1097. for (ALL_LIST_ELEMENTS_RO(pim_ifp->igmp_socket_list, sock_node, igmp)) {
  1098. char ifaddr_str[100];
  1099. struct listnode *grpnode;
  1100. struct igmp_group *grp;
  1101. pim_inet4_dump("<ifaddr?>", igmp->ifaddr, ifaddr_str, sizeof(ifaddr_str));
  1102. /* scan igmp groups */
  1103. for (ALL_LIST_ELEMENTS_RO(igmp->igmp_group_list, grpnode, grp)) {
  1104. char group_str[100];
  1105. struct listnode *srcnode;
  1106. struct igmp_source *src;
  1107. pim_inet4_dump("<group?>", grp->group_addr, group_str, sizeof(group_str));
  1108. /* scan group sources */
  1109. for (ALL_LIST_ELEMENTS_RO(grp->group_source_list, srcnode, src)) {
  1110. char source_str[100];
  1111. pim_inet4_dump("<source?>", src->source_addr, source_str, sizeof(source_str));
  1112. vty_out(vty, "%-9s %-15s %-15s %-15s %7d%s",
  1113. ifp->name,
  1114. ifaddr_str,
  1115. group_str,
  1116. source_str,
  1117. src->source_query_retransmit_count,
  1118. VTY_NEWLINE);
  1119. } /* scan group sources */
  1120. } /* scan igmp groups */
  1121. } /* scan igmp sockets */
  1122. } /* scan interfaces */
  1123. }
  1124. static void clear_igmp_interfaces()
  1125. {
  1126. struct listnode *ifnode;
  1127. struct listnode *ifnextnode;
  1128. struct interface *ifp;
  1129. for (ALL_LIST_ELEMENTS(iflist, ifnode, ifnextnode, ifp)) {
  1130. pim_if_addr_del_all_igmp(ifp);
  1131. }
  1132. for (ALL_LIST_ELEMENTS(iflist, ifnode, ifnextnode, ifp)) {
  1133. pim_if_addr_add_all(ifp);
  1134. }
  1135. }
  1136. static void clear_pim_interfaces()
  1137. {
  1138. struct listnode *ifnode;
  1139. struct listnode *ifnextnode;
  1140. struct interface *ifp;
  1141. for (ALL_LIST_ELEMENTS(iflist, ifnode, ifnextnode, ifp)) {
  1142. if (ifp->info) {
  1143. pim_neighbor_delete_all(ifp, "interface cleared");
  1144. }
  1145. }
  1146. }
  1147. static void clear_interfaces()
  1148. {
  1149. clear_igmp_interfaces();
  1150. clear_pim_interfaces();
  1151. }
  1152. DEFUN (pim_interface,
  1153. pim_interface_cmd,
  1154. "interface IFNAME",
  1155. "Select an interface to configure\n"
  1156. "Interface's name\n")
  1157. {
  1158. struct interface *ifp;
  1159. const char *ifname = argv[0];
  1160. size_t sl;
  1161. sl = strlen(ifname);
  1162. if (sl > INTERFACE_NAMSIZ) {
  1163. vty_out(vty, "%% Interface name %s is invalid: length exceeds "
  1164. "%d characters%s",
  1165. ifname, INTERFACE_NAMSIZ, VTY_NEWLINE);
  1166. return CMD_WARNING;
  1167. }
  1168. ifp = if_lookup_by_name_len(ifname, sl);
  1169. if (!ifp) {
  1170. vty_out(vty, "%% Interface %s does not exist%s", ifname, VTY_NEWLINE);
  1171. /* Returning here would prevent pimd from booting when there are
  1172. interface commands in pimd.conf, since all interfaces are
  1173. unknown at pimd boot time (the zebra daemon has not been
  1174. contacted for interface discovery). */
  1175. ifp = if_get_by_name_len(ifname, sl);
  1176. if (!ifp) {
  1177. vty_out(vty, "%% Could not create interface %s%s", ifname, VTY_NEWLINE);
  1178. return CMD_WARNING;
  1179. }
  1180. }
  1181. vty->index = ifp;
  1182. vty->node = INTERFACE_NODE;
  1183. return CMD_SUCCESS;
  1184. }
  1185. DEFUN (clear_ip_interfaces,
  1186. clear_ip_interfaces_cmd,
  1187. "clear ip interfaces",
  1188. CLEAR_STR
  1189. IP_STR
  1190. "Reset interfaces\n")
  1191. {
  1192. clear_interfaces();
  1193. return CMD_SUCCESS;
  1194. }
  1195. DEFUN (clear_ip_igmp_interfaces,
  1196. clear_ip_igmp_interfaces_cmd,
  1197. "clear ip igmp interfaces",
  1198. CLEAR_STR
  1199. IP_STR
  1200. CLEAR_IP_IGMP_STR
  1201. "Reset IGMP interfaces\n")
  1202. {
  1203. clear_igmp_interfaces();
  1204. return CMD_SUCCESS;
  1205. }
  1206. DEFUN (clear_ip_pim_interfaces,
  1207. clear_ip_pim_interfaces_cmd,
  1208. "clear ip pim interfaces",
  1209. CLEAR_STR
  1210. IP_STR
  1211. CLEAR_IP_PIM_STR
  1212. "Reset PIM interfaces\n")
  1213. {
  1214. clear_pim_interfaces();
  1215. return CMD_SUCCESS;
  1216. }
  1217. DEFUN (show_ip_igmp_interface,
  1218. show_ip_igmp_interface_cmd,
  1219. "show ip igmp interface",
  1220. SHOW_STR
  1221. IP_STR
  1222. IGMP_STR
  1223. "IGMP interface information\n")
  1224. {
  1225. igmp_show_interfaces(vty);
  1226. return CMD_SUCCESS;
  1227. }
  1228. DEFUN (show_ip_igmp_groups,
  1229. show_ip_igmp_groups_cmd,
  1230. "show ip igmp groups",
  1231. SHOW_STR
  1232. IP_STR
  1233. IGMP_STR
  1234. IGMP_GROUP_STR)
  1235. {
  1236. igmp_show_groups(vty);
  1237. return CMD_SUCCESS;
  1238. }
  1239. DEFUN (show_ip_igmp_groups_retransmissions,
  1240. show_ip_igmp_groups_retransmissions_cmd,
  1241. "show ip igmp groups retransmissions",
  1242. SHOW_STR
  1243. IP_STR
  1244. IGMP_STR
  1245. IGMP_GROUP_STR
  1246. "IGMP group retransmissions\n")
  1247. {
  1248. igmp_show_group_retransmission(vty);
  1249. return CMD_SUCCESS;
  1250. }
  1251. DEFUN (show_ip_igmp_parameters,
  1252. show_ip_igmp_parameters_cmd,
  1253. "show ip igmp parameters",
  1254. SHOW_STR
  1255. IP_STR
  1256. IGMP_STR
  1257. "IGMP parameters information\n")
  1258. {
  1259. igmp_show_parameters(vty);
  1260. return CMD_SUCCESS;
  1261. }
  1262. DEFUN (show_ip_igmp_sources,
  1263. show_ip_igmp_sources_cmd,
  1264. "show ip igmp sources",
  1265. SHOW_STR
  1266. IP_STR
  1267. IGMP_STR
  1268. IGMP_SOURCE_STR)
  1269. {
  1270. igmp_show_sources(vty);
  1271. return CMD_SUCCESS;
  1272. }
  1273. DEFUN (show_ip_igmp_sources_retransmissions,
  1274. show_ip_igmp_sources_retransmissions_cmd,
  1275. "show ip igmp sources retransmissions",
  1276. SHOW_STR
  1277. IP_STR
  1278. IGMP_STR
  1279. IGMP_SOURCE_STR
  1280. "IGMP source retransmissions\n")
  1281. {
  1282. igmp_show_source_retransmission(vty);
  1283. return CMD_SUCCESS;
  1284. }
  1285. DEFUN (show_ip_igmp_querier,
  1286. show_ip_igmp_querier_cmd,
  1287. "show ip igmp querier",
  1288. SHOW_STR
  1289. IP_STR
  1290. IGMP_STR
  1291. "IGMP querier information\n")
  1292. {
  1293. igmp_show_querier(vty);
  1294. return CMD_SUCCESS;
  1295. }
  1296. DEFUN (show_ip_pim_address,
  1297. show_ip_pim_address_cmd,
  1298. "show ip pim address",
  1299. SHOW_STR
  1300. IP_STR
  1301. PIM_STR
  1302. "PIM interface address\n")
  1303. {
  1304. show_interface_address(vty);
  1305. return CMD_SUCCESS;
  1306. }
  1307. DEFUN (show_ip_pim_assert,
  1308. show_ip_pim_assert_cmd,
  1309. "show ip pim assert",
  1310. SHOW_STR
  1311. IP_STR
  1312. PIM_STR
  1313. "PIM interface assert\n")
  1314. {
  1315. pim_show_assert(vty);
  1316. return CMD_SUCCESS;
  1317. }
  1318. DEFUN (show_ip_pim_assert_internal,
  1319. show_ip_pim_assert_internal_cmd,
  1320. "show ip pim assert-internal",
  1321. SHOW_STR
  1322. IP_STR
  1323. PIM_STR
  1324. "PIM interface internal assert state\n")
  1325. {
  1326. pim_show_assert_internal(vty);
  1327. return CMD_SUCCESS;
  1328. }
  1329. DEFUN (show_ip_pim_assert_metric,
  1330. show_ip_pim_assert_metric_cmd,
  1331. "show ip pim assert-metric",
  1332. SHOW_STR
  1333. IP_STR
  1334. PIM_STR
  1335. "PIM interface assert metric\n")
  1336. {
  1337. pim_show_assert_metric(vty);
  1338. return CMD_SUCCESS;
  1339. }
  1340. DEFUN (show_ip_pim_assert_winner_metric,
  1341. show_ip_pim_assert_winner_metric_cmd,
  1342. "show ip pim assert-winner-metric",
  1343. SHOW_STR
  1344. IP_STR
  1345. PIM_STR
  1346. "PIM interface assert winner metric\n")
  1347. {
  1348. pim_show_assert_winner_metric(vty);
  1349. return CMD_SUCCESS;
  1350. }
  1351. DEFUN (show_ip_pim_dr,
  1352. show_ip_pim_dr_cmd,
  1353. "show ip pim designated-router",
  1354. SHOW_STR
  1355. IP_STR
  1356. PIM_STR
  1357. "PIM interface designated router\n")
  1358. {
  1359. pim_show_dr(vty);
  1360. return CMD_SUCCESS;
  1361. }
  1362. DEFUN (show_ip_pim_hello,
  1363. show_ip_pim_hello_cmd,
  1364. "show ip pim hello",
  1365. SHOW_STR
  1366. IP_STR
  1367. PIM_STR
  1368. "PIM interface hello information\n")
  1369. {
  1370. pim_show_hello(vty);
  1371. return CMD_SUCCESS;
  1372. }
  1373. DEFUN (show_ip_pim_interface,
  1374. show_ip_pim_interface_cmd,
  1375. "show ip pim interface",
  1376. SHOW_STR
  1377. IP_STR
  1378. PIM_STR
  1379. "PIM interface information\n")
  1380. {
  1381. pim_show_interfaces(vty);
  1382. return CMD_SUCCESS;
  1383. }
  1384. DEFUN (show_ip_pim_join,
  1385. show_ip_pim_join_cmd,
  1386. "show ip pim join",
  1387. SHOW_STR
  1388. IP_STR
  1389. PIM_STR
  1390. "PIM interface join information\n")
  1391. {
  1392. pim_show_join(vty);
  1393. return CMD_SUCCESS;
  1394. }
  1395. DEFUN (show_ip_pim_lan_prune_delay,
  1396. show_ip_pim_lan_prune_delay_cmd,
  1397. "show ip pim lan-prune-delay",
  1398. SHOW_STR
  1399. IP_STR
  1400. PIM_STR
  1401. "PIM neighbors LAN prune delay parameters\n")
  1402. {
  1403. pim_show_lan_prune_delay(vty);
  1404. return CMD_SUCCESS;
  1405. }
  1406. DEFUN (show_ip_pim_local_membership,
  1407. show_ip_pim_local_membership_cmd,
  1408. "show ip pim local-membership",
  1409. SHOW_STR
  1410. IP_STR
  1411. PIM_STR
  1412. "PIM interface local-membership\n")
  1413. {
  1414. pim_show_membership(vty);
  1415. return CMD_SUCCESS;
  1416. }
  1417. DEFUN (show_ip_pim_jp_override_interval,
  1418. show_ip_pim_jp_override_interval_cmd,
  1419. "show ip pim jp-override-interval",
  1420. SHOW_STR
  1421. IP_STR
  1422. PIM_STR
  1423. "PIM interface J/P override interval\n")
  1424. {
  1425. pim_show_jp_override_interval(vty);
  1426. return CMD_SUCCESS;
  1427. }
  1428. DEFUN (show_ip_pim_neighbor,
  1429. show_ip_pim_neighbor_cmd,
  1430. "show ip pim neighbor",
  1431. SHOW_STR
  1432. IP_STR
  1433. PIM_STR
  1434. "PIM neighbor information\n")
  1435. {
  1436. pim_show_neighbors(vty);
  1437. return CMD_SUCCESS;
  1438. }
  1439. DEFUN (show_ip_pim_secondary,
  1440. show_ip_pim_secondary_cmd,
  1441. "show ip pim secondary",
  1442. SHOW_STR
  1443. IP_STR
  1444. PIM_STR
  1445. "PIM neighbor addresses\n")
  1446. {
  1447. pim_show_neighbors_secondary(vty);
  1448. return CMD_SUCCESS;
  1449. }
  1450. DEFUN (show_ip_pim_upstream,
  1451. show_ip_pim_upstream_cmd,
  1452. "show ip pim upstream",
  1453. SHOW_STR
  1454. IP_STR
  1455. PIM_STR
  1456. "PIM upstream information\n")
  1457. {
  1458. pim_show_upstream(vty);
  1459. return CMD_SUCCESS;
  1460. }
  1461. DEFUN (show_ip_pim_upstream_join_desired,
  1462. show_ip_pim_upstream_join_desired_cmd,
  1463. "show ip pim upstream-join-desired",
  1464. SHOW_STR
  1465. IP_STR
  1466. PIM_STR
  1467. "PIM upstream join-desired\n")
  1468. {
  1469. pim_show_join_desired(vty);
  1470. return CMD_SUCCESS;
  1471. }
  1472. DEFUN (show_ip_pim_upstream_rpf,
  1473. show_ip_pim_upstream_rpf_cmd,
  1474. "show ip pim upstream-rpf",
  1475. SHOW_STR
  1476. IP_STR
  1477. PIM_STR
  1478. "PIM upstream source rpf\n")
  1479. {
  1480. pim_show_upstream_rpf(vty);
  1481. return CMD_SUCCESS;
  1482. }
  1483. DEFUN (show_ip_pim_rpf,
  1484. show_ip_pim_rpf_cmd,
  1485. "show ip pim rpf",
  1486. SHOW_STR
  1487. IP_STR
  1488. PIM_STR
  1489. "PIM cached source rpf information\n")
  1490. {
  1491. pim_show_rpf(vty);
  1492. return CMD_SUCCESS;
  1493. }
  1494. static void show_multicast_interfaces(struct vty *vty)
  1495. {
  1496. struct listnode *node;
  1497. struct interface *ifp;
  1498. vty_out(vty, "%s", VTY_NEWLINE);
  1499. vty_out(vty, "Interface Address ifi Vif PktsIn PktsOut BytesIn BytesOut%s",
  1500. VTY_NEWLINE);
  1501. for (ALL_LIST_ELEMENTS_RO(iflist, node, ifp)) {
  1502. struct pim_interface *pim_ifp;
  1503. struct in_addr ifaddr;
  1504. struct sioc_vif_req vreq;
  1505. pim_ifp = ifp->info;
  1506. if (!pim_ifp)
  1507. continue;
  1508. memset(&vreq, 0, sizeof(vreq));
  1509. vreq.vifi = pim_ifp->mroute_vif_index;
  1510. if (ioctl(qpim_mroute_socket_fd, SIOCGETVIFCNT, &vreq)) {
  1511. int e = errno;
  1512. vty_out(vty,
  1513. "ioctl(SIOCGETVIFCNT=%d) failure for interface %s vif_index=%d: errno=%d: %s%s",
  1514. SIOCGETVIFCNT,
  1515. ifp->name,
  1516. pim_ifp->mroute_vif_index,
  1517. e,
  1518. safe_strerror(e),
  1519. VTY_NEWLINE);
  1520. continue;
  1521. }
  1522. ifaddr = pim_ifp->primary_address;
  1523. vty_out(vty, "%-9s %-15s %3d %3d %7lu %7lu %10lu %10lu%s",
  1524. ifp->name,
  1525. inet_ntoa(ifaddr),
  1526. ifp->ifindex,
  1527. pim_ifp->mroute_vif_index,
  1528. vreq.icount,
  1529. vreq.ocount,
  1530. vreq.ibytes,
  1531. vreq.obytes,
  1532. VTY_NEWLINE);
  1533. }
  1534. }
  1535. DEFUN (show_ip_multicast,
  1536. show_ip_multicast_cmd,
  1537. "show ip multicast",
  1538. SHOW_STR
  1539. IP_STR
  1540. "Multicast global information\n")
  1541. {
  1542. time_t now = pim_time_monotonic_sec();
  1543. if (PIM_MROUTE_IS_ENABLED) {
  1544. char uptime[10];
  1545. vty_out(vty, "Mroute socket descriptor: %d%s",
  1546. qpim_mroute_socket_fd,
  1547. VTY_NEWLINE);
  1548. pim_time_uptime(uptime, sizeof(uptime), now - qpim_mroute_socket_creation);
  1549. vty_out(vty, "Mroute socket uptime: %s%s",
  1550. uptime,
  1551. VTY_NEWLINE);
  1552. }
  1553. else {
  1554. vty_out(vty, "Multicast disabled%s",
  1555. VTY_NEWLINE);
  1556. }
  1557. vty_out(vty, "%s", VTY_NEWLINE);
  1558. vty_out(vty, "Current highest VifIndex: %d%s",
  1559. qpim_mroute_oif_highest_vif_index,
  1560. VTY_NEWLINE);
  1561. vty_out(vty, "Maximum highest VifIndex: %d%s",
  1562. MAXVIFS - 1,
  1563. VTY_NEWLINE);
  1564. vty_out(vty, "%s", VTY_NEWLINE);
  1565. vty_out(vty, "Upstream Join Timer: %d secs%s",
  1566. qpim_t_periodic,
  1567. VTY_NEWLINE);
  1568. vty_out(vty, "Join/Prune Holdtime: %d secs%s",
  1569. PIM_JP_HOLDTIME,
  1570. VTY_NEWLINE);
  1571. vty_out(vty, "%s", VTY_NEWLINE);
  1572. show_rpf_refresh_stats(vty, now);
  1573. show_multicast_interfaces(vty);
  1574. return CMD_SUCCESS;
  1575. }
  1576. static void show_mroute(struct vty *vty)
  1577. {
  1578. struct listnode *node;
  1579. struct channel_oil *c_oil;
  1580. time_t now;
  1581. vty_out(vty, "Proto: I=IGMP P=PIM%s%s", VTY_NEWLINE, VTY_NEWLINE);
  1582. vty_out(vty, "Source Group Proto Input iVifI Output oVifI TTL Uptime %s",
  1583. VTY_NEWLINE);
  1584. now = pim_time_monotonic_sec();
  1585. for (ALL_LIST_ELEMENTS_RO(qpim_channel_oil_list, node, c_oil)) {
  1586. char group_str[100];
  1587. char source_str[100];
  1588. int oif_vif_index;
  1589. pim_inet4_dump("<group?>", c_oil->oil.mfcc_mcastgrp, group_str, sizeof(group_str));
  1590. pim_inet4_dump("<source?>", c_oil->oil.mfcc_origin, source_str, sizeof(source_str));
  1591. for (oif_vif_index = 0; oif_vif_index < MAXVIFS; ++oif_vif_index) {
  1592. struct interface *ifp_in;
  1593. struct interface *ifp_out;
  1594. char oif_uptime[10];
  1595. int ttl;
  1596. char proto[5];
  1597. ttl = c_oil->oil.mfcc_ttls[oif_vif_index];
  1598. if (ttl < 1)
  1599. continue;
  1600. ifp_in = pim_if_find_by_vif_index(c_oil->oil.mfcc_parent);
  1601. ifp_out = pim_if_find_by_vif_index(oif_vif_index);
  1602. pim_time_uptime(oif_uptime, sizeof(oif_uptime), now - c_oil->oif_creation[oif_vif_index]);
  1603. proto[0] = '\0';
  1604. if (c_oil->oif_flags[oif_vif_index] & PIM_OIF_FLAG_PROTO_PIM) {
  1605. strcat(proto, "P");
  1606. }
  1607. if (c_oil->oif_flags[oif_vif_index] & PIM_OIF_FLAG_PROTO_IGMP) {
  1608. strcat(proto, "I");
  1609. }
  1610. vty_out(vty, "%-15s %-15s %-5s %-5s %5d %-6s %5d %3d %8s %s",
  1611. source_str,
  1612. group_str,
  1613. proto,
  1614. ifp_in ? ifp_in->name : "<iif?>",
  1615. c_oil->oil.mfcc_parent,
  1616. ifp_out ? ifp_out->name : "<oif?>",
  1617. oif_vif_index,
  1618. ttl,
  1619. oif_uptime,
  1620. VTY_NEWLINE);
  1621. }
  1622. }
  1623. }
  1624. DEFUN (show_ip_mroute,
  1625. show_ip_mroute_cmd,
  1626. "show ip mroute",
  1627. SHOW_STR
  1628. IP_STR
  1629. MROUTE_STR)
  1630. {
  1631. show_mroute(vty);
  1632. return CMD_SUCCESS;
  1633. }
  1634. static void show_mroute_count(struct vty *vty)
  1635. {
  1636. struct listnode *node;
  1637. struct channel_oil *c_oil;
  1638. vty_out(vty, "%s", VTY_NEWLINE);
  1639. vty_out(vty, "Source Group Packets Bytes WrongIf %s",
  1640. VTY_NEWLINE);
  1641. for (ALL_LIST_ELEMENTS_RO(qpim_channel_oil_list, node, c_oil)) {
  1642. char group_str[100];
  1643. char source_str[100];
  1644. struct sioc_sg_req sgreq;
  1645. memset(&sgreq, 0, sizeof(sgreq));
  1646. sgreq.src = c_oil->oil.mfcc_origin;
  1647. sgreq.grp = c_oil->oil.mfcc_mcastgrp;
  1648. pim_inet4_dump("<group?>", c_oil->oil.mfcc_mcastgrp, group_str, sizeof(group_str));
  1649. pim_inet4_dump("<source?>", c_oil->oil.mfcc_origin, source_str, sizeof(source_str));
  1650. if (ioctl(qpim_mroute_socket_fd, SIOCGETSGCNT, &sgreq)) {
  1651. int e = errno;
  1652. vty_out(vty,
  1653. "ioctl(SIOCGETSGCNT=%d) failure for (S,G)=(%s,%s): errno=%d: %s%s",
  1654. SIOCGETSGCNT,
  1655. source_str,
  1656. group_str,
  1657. e,
  1658. safe_strerror(e),
  1659. VTY_NEWLINE);
  1660. continue;
  1661. }
  1662. vty_out(vty, "%-15s %-15s %7ld %10ld %7ld %s",
  1663. source_str,
  1664. group_str,
  1665. sgreq.pktcnt,
  1666. sgreq.bytecnt,
  1667. sgreq.wrong_if,
  1668. VTY_NEWLINE);
  1669. }
  1670. }
  1671. DEFUN (show_ip_mroute_count,
  1672. show_ip_mroute_count_cmd,
  1673. "show ip mroute count",
  1674. SHOW_STR
  1675. IP_STR
  1676. MROUTE_STR
  1677. "Route and packet count data\n")
  1678. {
  1679. show_mroute_count(vty);
  1680. return CMD_SUCCESS;
  1681. }
  1682. DEFUN (show_ip_route,
  1683. show_ip_route_cmd,
  1684. "show ip route A.B.C.D",
  1685. SHOW_STR
  1686. IP_STR
  1687. ROUTE_STR
  1688. "Unicast address\n")
  1689. {
  1690. struct in_addr addr;
  1691. const char *addr_str;
  1692. struct pim_nexthop nexthop;
  1693. char nexthop_addr_str[100];
  1694. int result;
  1695. addr_str = argv[0];
  1696. result = inet_pton(AF_INET, addr_str, &addr);
  1697. if (result <= 0) {
  1698. vty_out(vty, "Bad unicast address %s: errno=%d: %s%s",
  1699. addr_str, errno, safe_strerror(errno), VTY_NEWLINE);
  1700. return CMD_WARNING;
  1701. }
  1702. if (pim_nexthop_lookup(&nexthop, addr)) {
  1703. vty_out(vty, "Failure querying RIB nexthop for unicast address %s%s",
  1704. addr_str, VTY_NEWLINE);
  1705. return CMD_WARNING;
  1706. }
  1707. vty_out(vty, "Address NextHop Interface Metric Preference%s",
  1708. VTY_NEWLINE);
  1709. pim_inet4_dump("<nexthop?>", nexthop.mrib_nexthop_addr,
  1710. nexthop_addr_str, sizeof(nexthop_addr_str));
  1711. vty_out(vty, "%-15s %-15s %-9s %6d %10d%s",
  1712. addr_str,
  1713. nexthop_addr_str,
  1714. nexthop.interface ? nexthop.interface->name : "<ifname?>",
  1715. nexthop.mrib_route_metric,
  1716. nexthop.mrib_metric_preference,
  1717. VTY_NEWLINE);
  1718. return CMD_SUCCESS;
  1719. }
  1720. static void show_ssmpingd(struct vty *vty)
  1721. {
  1722. struct listnode *node;
  1723. struct ssmpingd_sock *ss;
  1724. time_t now;
  1725. vty_out(vty, "Source Socket Uptime Requests%s",
  1726. VTY_NEWLINE);
  1727. if (!qpim_ssmpingd_list)
  1728. return;
  1729. now = pim_time_monotonic_sec();
  1730. for (ALL_LIST_ELEMENTS_RO(qpim_ssmpingd_list, node, ss)) {
  1731. char source_str[100];
  1732. char ss_uptime[10];
  1733. pim_inet4_dump("<src?>", ss->source_addr, source_str, sizeof(source_str));
  1734. pim_time_uptime(ss_uptime, sizeof(ss_uptime), now - ss->creation);
  1735. vty_out(vty, "%-15s %6d %8s %8lld%s",
  1736. source_str,
  1737. ss->sock_fd,
  1738. ss_uptime,
  1739. ss->requests,
  1740. VTY_NEWLINE);
  1741. }
  1742. }
  1743. DEFUN (show_ip_ssmpingd,
  1744. show_ip_ssmpingd_cmd,
  1745. "show ip ssmpingd",
  1746. SHOW_STR
  1747. IP_STR
  1748. SHOW_SSMPINGD_STR)
  1749. {
  1750. show_ssmpingd(vty);
  1751. return CMD_SUCCESS;
  1752. }
  1753. static void mroute_add_all()
  1754. {
  1755. struct listnode *node;
  1756. struct channel_oil *c_oil;
  1757. for (ALL_LIST_ELEMENTS_RO(qpim_channel_oil_list, node, c_oil)) {
  1758. if (pim_mroute_add(&c_oil->oil)) {
  1759. /* just log warning */
  1760. char source_str[100];
  1761. char group_str[100];
  1762. pim_inet4_dump("<source?>", c_oil->oil.mfcc_origin, source_str, sizeof(source_str));
  1763. pim_inet4_dump("<group?>", c_oil->oil.mfcc_mcastgrp, group_str, sizeof(group_str));
  1764. zlog_warn("%s %s: (S,G)=(%s,%s) failure writing MFC",
  1765. __FILE__, __PRETTY_FUNCTION__,
  1766. source_str, group_str);
  1767. }
  1768. }
  1769. }
  1770. static void mroute_del_all()
  1771. {
  1772. struct listnode *node;
  1773. struct channel_oil *c_oil;
  1774. for (ALL_LIST_ELEMENTS_RO(qpim_channel_oil_list, node, c_oil)) {
  1775. if (pim_mroute_del(&c_oil->oil)) {
  1776. /* just log warning */
  1777. char source_str[100];
  1778. char group_str[100];
  1779. pim_inet4_dump("<source?>", c_oil->oil.mfcc_origin, source_str, sizeof(source_str));
  1780. pim_inet4_dump("<group?>", c_oil->oil.mfcc_mcastgrp, group_str, sizeof(group_str));
  1781. zlog_warn("%s %s: (S,G)=(%s,%s) failure clearing MFC",
  1782. __FILE__, __PRETTY_FUNCTION__,
  1783. source_str, group_str);
  1784. }
  1785. }
  1786. }
  1787. DEFUN (ip_multicast_routing,
  1788. ip_multicast_routing_cmd,
  1789. PIM_CMD_IP_MULTICAST_ROUTING,
  1790. IP_STR
  1791. "Enable IP multicast forwarding\n")
  1792. {
  1793. pim_mroute_socket_enable();
  1794. pim_if_add_vif_all();
  1795. mroute_add_all();
  1796. return CMD_SUCCESS;
  1797. }
  1798. DEFUN (no_ip_multicast_routing,
  1799. no_ip_multicast_routing_cmd,
  1800. PIM_CMD_NO " " PIM_CMD_IP_MULTICAST_ROUTING,
  1801. NO_STR
  1802. IP_STR
  1803. "Global IP configuration subcommands\n"
  1804. "Enable IP multicast forwarding\n")
  1805. {
  1806. mroute_del_all();
  1807. pim_if_del_vif_all();
  1808. pim_mroute_socket_disable();
  1809. return CMD_SUCCESS;
  1810. }
  1811. DEFUN (ip_ssmpingd,
  1812. ip_ssmpingd_cmd,
  1813. "ip ssmpingd [A.B.C.D]",
  1814. IP_STR
  1815. CONF_SSMPINGD_STR
  1816. "Source address\n")
  1817. {
  1818. int result;
  1819. struct in_addr source_addr;
  1820. const char *source_str = (argc > 0) ? argv[0] : "0.0.0.0";
  1821. result = inet_pton(AF_INET, source_str, &source_addr);
  1822. if (result <= 0) {
  1823. vty_out(vty, "%% Bad source address %s: errno=%d: %s%s",
  1824. source_str, errno, safe_strerror(errno), VTY_NEWLINE);
  1825. return CMD_WARNING;
  1826. }
  1827. result = pim_ssmpingd_start(source_addr);
  1828. if (result) {
  1829. vty_out(vty, "%% Failure starting ssmpingd for source %s: %d%s",
  1830. source_str, result, VTY_NEWLINE);
  1831. return CMD_WARNING;
  1832. }
  1833. return CMD_SUCCESS;
  1834. }
  1835. DEFUN (no_ip_ssmpingd,
  1836. no_ip_ssmpingd_cmd,
  1837. "no ip ssmpingd [A.B.C.D]",
  1838. NO_STR
  1839. IP_STR
  1840. CONF_SSMPINGD_STR
  1841. "Source address\n")
  1842. {
  1843. int result;
  1844. struct in_addr source_addr;
  1845. const char *source_str = (argc > 0) ? argv[0] : "0.0.0.0";
  1846. result = inet_pton(AF_INET, source_str, &source_addr);
  1847. if (result <= 0) {
  1848. vty_out(vty, "%% Bad source address %s: errno=%d: %s%s",
  1849. source_str, errno, safe_strerror(errno), VTY_NEWLINE);
  1850. return CMD_WARNING;
  1851. }
  1852. result = pim_ssmpingd_stop(source_addr);
  1853. if (result) {
  1854. vty_out(vty, "%% Failure stopping ssmpingd for source %s: %d%s",
  1855. source_str, result, VTY_NEWLINE);
  1856. return CMD_WARNING;
  1857. }
  1858. return CMD_SUCCESS;
  1859. }
  1860. DEFUN (interface_ip_igmp,
  1861. interface_ip_igmp_cmd,
  1862. "ip igmp",
  1863. IP_STR
  1864. IFACE_IGMP_STR)
  1865. {
  1866. struct interface *ifp;
  1867. struct pim_interface *pim_ifp;
  1868. ifp = vty->index;
  1869. pim_ifp = ifp->info;
  1870. if (!pim_ifp) {
  1871. pim_ifp = pim_if_new(ifp, 1 /* igmp=true */, 0 /* pim=false */);
  1872. if (!pim_ifp) {
  1873. vty_out(vty, "Could not enable IGMP on interface %s%s",
  1874. ifp->name, VTY_NEWLINE);
  1875. return CMD_WARNING;
  1876. }
  1877. }
  1878. else {
  1879. PIM_IF_DO_IGMP(pim_ifp->options);
  1880. }
  1881. pim_if_addr_add_all(ifp);
  1882. pim_if_membership_refresh(ifp);
  1883. return CMD_SUCCESS;
  1884. }
  1885. DEFUN (interface_no_ip_igmp,
  1886. interface_no_ip_igmp_cmd,
  1887. "no ip igmp",
  1888. NO_STR
  1889. IP_STR
  1890. IFACE_IGMP_STR)
  1891. {
  1892. struct interface *ifp;
  1893. struct pim_interface *pim_ifp;
  1894. ifp = vty->index;
  1895. pim_ifp = ifp->info;
  1896. if (!pim_ifp)
  1897. return CMD_SUCCESS;
  1898. PIM_IF_DONT_IGMP(pim_ifp->options);
  1899. pim_if_membership_clear(ifp);
  1900. pim_if_addr_del_all(ifp);
  1901. if (!PIM_IF_TEST_PIM(pim_ifp->options)) {
  1902. pim_if_delete(ifp);
  1903. }
  1904. return CMD_SUCCESS;
  1905. }
  1906. DEFUN (interface_ip_igmp_join,
  1907. interface_ip_igmp_join_cmd,
  1908. "ip igmp join A.B.C.D A.B.C.D",
  1909. IP_STR
  1910. IFACE_IGMP_STR
  1911. "IGMP join multicast group\n"
  1912. "Multicast group address\n"
  1913. "Source address\n")
  1914. {
  1915. struct interface *ifp;
  1916. const char *group_str;
  1917. const char *source_str;
  1918. struct in_addr group_addr;
  1919. struct in_addr source_addr;
  1920. int result;
  1921. ifp = vty->index;
  1922. /* Group address */
  1923. group_str = argv[0];
  1924. result = inet_pton(AF_INET, group_str, &group_addr);
  1925. if (result <= 0) {
  1926. vty_out(vty, "Bad group address %s: errno=%d: %s%s",
  1927. group_str, errno, safe_strerror(errno), VTY_NEWLINE);
  1928. return CMD_WARNING;
  1929. }
  1930. /* Source address */
  1931. source_str = argv[1];
  1932. result = inet_pton(AF_INET, source_str, &source_addr);
  1933. if (result <= 0) {
  1934. vty_out(vty, "Bad source address %s: errno=%d: %s%s",
  1935. source_str, errno, safe_strerror(errno), VTY_NEWLINE);
  1936. return CMD_WARNING;
  1937. }
  1938. result = pim_if_igmp_join_add(ifp, group_addr, source_addr);
  1939. if (result) {
  1940. vty_out(vty, "%% Failure joining IGMP group %s source %s on interface %s: %d%s",
  1941. group_str, source_str, ifp->name, result, VTY_NEWLINE);
  1942. return CMD_WARNING;
  1943. }
  1944. return CMD_SUCCESS;
  1945. }
  1946. DEFUN (interface_no_ip_igmp_join,
  1947. interface_no_ip_igmp_join_cmd,
  1948. "no ip igmp join A.B.C.D A.B.C.D",
  1949. NO_STR
  1950. IP_STR
  1951. IFACE_IGMP_STR
  1952. "IGMP join multicast group\n"
  1953. "Multicast group address\n"
  1954. "Source address\n")
  1955. {
  1956. struct interface *ifp;
  1957. const char *group_str;
  1958. const char *source_str;
  1959. struct in_addr group_addr;
  1960. struct in_addr source_addr;
  1961. int result;
  1962. ifp = vty->index;
  1963. /* Group address */
  1964. group_str = argv[0];
  1965. result = inet_pton(AF_INET, group_str, &group_addr);
  1966. if (result <= 0) {
  1967. vty_out(vty, "Bad group address %s: errno=%d: %s%s",
  1968. group_str, errno, safe_strerror(errno), VTY_NEWLINE);
  1969. return CMD_WARNING;
  1970. }
  1971. /* Source address */
  1972. source_str = argv[1];
  1973. result = inet_pton(AF_INET, source_str, &source_addr);
  1974. if (result <= 0) {
  1975. vty_out(vty, "Bad source address %s: errno=%d: %s%s",
  1976. source_str, errno, safe_strerror(errno), VTY_NEWLINE);
  1977. return CMD_WARNING;
  1978. }
  1979. result = pim_if_igmp_join_del(ifp, group_addr, source_addr);
  1980. if (result) {
  1981. vty_out(vty, "%% Failure leaving IGMP group %s source %s on interface %s: %d%s",
  1982. group_str, source_str, ifp->name, result, VTY_NEWLINE);
  1983. return CMD_WARNING;
  1984. }
  1985. return CMD_SUCCESS;
  1986. }
  1987. /*
  1988. CLI reconfiguration affects the interface level (struct pim_interface).
  1989. This function propagates the reconfiguration to every active socket
  1990. for that interface.
  1991. */
  1992. static void igmp_sock_query_interval_reconfig(struct igmp_sock *igmp)
  1993. {
  1994. struct interface *ifp;
  1995. struct pim_interface *pim_ifp;
  1996. zassert(igmp);
  1997. /* other querier present? */
  1998. if (igmp->t_other_querier_timer)
  1999. return;
  2000. /* this is the querier */
  2001. zassert(igmp->interface);
  2002. zassert(igmp->interface->info);
  2003. ifp = igmp->interface;
  2004. pim_ifp = ifp->info;
  2005. if (PIM_DEBUG_IGMP_TRACE) {
  2006. char ifaddr_str[100];
  2007. pim_inet4_dump("<ifaddr?>", igmp->ifaddr, ifaddr_str, sizeof(ifaddr_str));
  2008. zlog_debug("%s: Querier %s on %s reconfig query_interval=%d",
  2009. __PRETTY_FUNCTION__,
  2010. ifaddr_str,
  2011. ifp->name,
  2012. pim_ifp->igmp_default_query_interval);
  2013. }
  2014. /*
  2015. igmp_startup_mode_on() will reset QQI:
  2016. igmp->querier_query_interval = pim_ifp->igmp_default_query_interval;
  2017. */
  2018. igmp_startup_mode_on(igmp);
  2019. }
  2020. static void igmp_sock_query_reschedule(struct igmp_sock *igmp)
  2021. {
  2022. if (igmp->t_igmp_query_timer) {
  2023. /* other querier present */
  2024. zassert(igmp->t_igmp_query_timer);
  2025. zassert(!igmp->t_other_querier_timer);
  2026. pim_igmp_general_query_off(igmp);
  2027. pim_igmp_general_query_on(igmp);
  2028. zassert(igmp->t_igmp_query_timer);
  2029. zassert(!igmp->t_other_querier_timer);
  2030. }
  2031. else {
  2032. /* this is the querier */
  2033. zassert(!igmp->t_igmp_query_timer);
  2034. zassert(igmp->t_other_querier_timer);
  2035. pim_igmp_other_querier_timer_off(igmp);
  2036. pim_igmp_other_querier_timer_on(igmp);
  2037. zassert(!igmp->t_igmp_query_timer);
  2038. zassert(igmp->t_other_querier_timer);
  2039. }
  2040. }
  2041. static void change_query_interval(struct pim_interface *pim_ifp,
  2042. int query_interval)
  2043. {
  2044. struct listnode *sock_node;
  2045. struct igmp_sock *igmp;
  2046. pim_ifp->igmp_default_query_interval = query_interval;
  2047. for (ALL_LIST_ELEMENTS_RO(pim_ifp->igmp_socket_list, sock_node, igmp)) {
  2048. igmp_sock_query_interval_reconfig(igmp);
  2049. igmp_sock_query_reschedule(igmp);
  2050. }
  2051. }
  2052. static void change_query_max_response_time(struct pim_interface *pim_ifp,
  2053. int query_max_response_time_dsec)
  2054. {
  2055. struct listnode *sock_node;
  2056. struct igmp_sock *igmp;
  2057. pim_ifp->igmp_query_max_response_time_dsec = query_max_response_time_dsec;
  2058. /*
  2059. Below we modify socket/group/source timers in order to quickly
  2060. reflect the change. Otherwise, those timers would eventually catch
  2061. up.
  2062. */
  2063. /* scan all sockets */
  2064. for (ALL_LIST_ELEMENTS_RO(pim_ifp->igmp_socket_list, sock_node, igmp)) {
  2065. struct listnode *grp_node;
  2066. struct igmp_group *grp;
  2067. /* reschedule socket general query */
  2068. igmp_sock_query_reschedule(igmp);
  2069. /* scan socket groups */
  2070. for (ALL_LIST_ELEMENTS_RO(igmp->igmp_group_list, grp_node, grp)) {
  2071. struct listnode *src_node;
  2072. struct igmp_source *src;
  2073. /* reset group timers for groups in EXCLUDE mode */
  2074. if (grp->group_filtermode_isexcl) {
  2075. igmp_group_reset_gmi(grp);
  2076. }
  2077. /* scan group sources */
  2078. for (ALL_LIST_ELEMENTS_RO(grp->group_source_list, src_node, src)) {
  2079. /* reset source timers for sources with running timers */
  2080. if (src->t_source_timer) {
  2081. igmp_source_reset_gmi(igmp, grp, src);
  2082. }
  2083. }
  2084. }
  2085. }
  2086. }
  2087. #define IGMP_QUERY_INTERVAL_MIN (1)
  2088. #define IGMP_QUERY_INTERVAL_MAX (1800)
  2089. DEFUN (interface_ip_igmp_query_interval,
  2090. interface_ip_igmp_query_interval_cmd,
  2091. PIM_CMD_IP_IGMP_QUERY_INTERVAL " <1-1800>",
  2092. IP_STR
  2093. IFACE_IGMP_STR
  2094. IFACE_IGMP_QUERY_INTERVAL_STR
  2095. "Query interval in seconds\n")
  2096. {
  2097. struct interface *ifp;
  2098. struct pim_interface *pim_ifp;
  2099. int query_interval;
  2100. int query_interval_dsec;
  2101. ifp = vty->index;
  2102. pim_ifp = ifp->info;
  2103. if (!pim_ifp) {
  2104. vty_out(vty,
  2105. "IGMP not enabled on interface %s. Please enable IGMP first.%s",
  2106. ifp->name,
  2107. VTY_NEWLINE);
  2108. return CMD_WARNING;
  2109. }
  2110. query_interval = atoi(argv[0]);
  2111. query_interval_dsec = 10 * query_interval;
  2112. /*
  2113. It seems we don't need to check bounds since command.c does it
  2114. already, but we verify them anyway for extra safety.
  2115. */
  2116. if (query_interval < IGMP_QUERY_INTERVAL_MIN) {
  2117. vty_out(vty, "General query interval %d lower than minimum %d%s",
  2118. query_interval,
  2119. IGMP_QUERY_INTERVAL_MIN,
  2120. VTY_NEWLINE);
  2121. return CMD_WARNING;
  2122. }
  2123. if (query_interval > IGMP_QUERY_INTERVAL_MAX) {
  2124. vty_out(vty, "General query interval %d higher than maximum %d%s",
  2125. query_interval,
  2126. IGMP_QUERY_INTERVAL_MAX,
  2127. VTY_NEWLINE);
  2128. return CMD_WARNING;
  2129. }
  2130. if (query_interval_dsec <= pim_ifp->igmp_query_max_response_time_dsec) {
  2131. vty_out(vty,
  2132. "Can't set general query interval %d dsec <= query max response time %d dsec.%s",
  2133. query_interval_dsec, pim_ifp->igmp_query_max_response_time_dsec,
  2134. VTY_NEWLINE);
  2135. return CMD_WARNING;
  2136. }
  2137. change_query_interval(pim_ifp, query_interval);
  2138. return CMD_SUCCESS;
  2139. }
  2140. DEFUN (interface_no_ip_igmp_query_interval,
  2141. interface_no_ip_igmp_query_interval_cmd,
  2142. PIM_CMD_NO " " PIM_CMD_IP_IGMP_QUERY_INTERVAL,
  2143. NO_STR
  2144. IP_STR
  2145. IFACE_IGMP_STR
  2146. IFACE_IGMP_QUERY_INTERVAL_STR)
  2147. {
  2148. struct interface *ifp;
  2149. struct pim_interface *pim_ifp;
  2150. int default_query_interval_dsec;
  2151. ifp = vty->index;
  2152. pim_ifp = ifp->info;
  2153. if (!pim_ifp)
  2154. return CMD_SUCCESS;
  2155. default_query_interval_dsec = IGMP_GENERAL_QUERY_INTERVAL * 10;
  2156. if (default_query_interval_dsec <= pim_ifp->igmp_query_max_response_time_dsec) {
  2157. vty_out(vty,
  2158. "Can't set default general query interval %d dsec <= query max response time %d dsec.%s",
  2159. default_query_interval_dsec, pim_ifp->igmp_query_max_response_time_dsec,
  2160. VTY_NEWLINE);
  2161. return CMD_WARNING;
  2162. }
  2163. change_query_interval(pim_ifp, IGMP_GENERAL_QUERY_INTERVAL);
  2164. return CMD_SUCCESS;
  2165. }
  2166. #define IGMP_QUERY_MAX_RESPONSE_TIME_MIN (1)
  2167. #define IGMP_QUERY_MAX_RESPONSE_TIME_MAX (25)
  2168. DEFUN (interface_ip_igmp_query_max_response_time,
  2169. interface_ip_igmp_query_max_response_time_cmd,
  2170. PIM_CMD_IP_IGMP_QUERY_MAX_RESPONSE_TIME " <1-25>",
  2171. IP_STR
  2172. IFACE_IGMP_STR
  2173. IFACE_IGMP_QUERY_MAX_RESPONSE_TIME_STR
  2174. "Query response value in seconds\n")
  2175. {
  2176. struct interface *ifp;
  2177. struct pim_interface *pim_ifp;
  2178. int query_max_response_time;
  2179. ifp = vty->index;
  2180. pim_ifp = ifp->info;
  2181. if (!pim_ifp) {
  2182. vty_out(vty,
  2183. "IGMP not enabled on interface %s. Please enable IGMP first.%s",
  2184. ifp->name,
  2185. VTY_NEWLINE);
  2186. return CMD_WARNING;
  2187. }
  2188. query_max_response_time = atoi(argv[0]);
  2189. /*
  2190. It seems we don't need to check bounds since command.c does it
  2191. already, but we verify them anyway for extra safety.
  2192. */
  2193. if (query_max_response_time < IGMP_QUERY_MAX_RESPONSE_TIME_MIN) {
  2194. vty_out(vty, "Query max response time %d sec lower than minimum %d sec%s",
  2195. query_max_response_time,
  2196. IGMP_QUERY_MAX_RESPONSE_TIME_MIN,
  2197. VTY_NEWLINE);
  2198. return CMD_WARNING;
  2199. }
  2200. if (query_max_response_time > IGMP_QUERY_MAX_RESPONSE_TIME_MAX) {
  2201. vty_out(vty, "Query max response time %d sec higher than maximum %d sec%s",
  2202. query_max_response_time,
  2203. IGMP_QUERY_MAX_RESPONSE_TIME_MAX,
  2204. VTY_NEWLINE);
  2205. return CMD_WARNING;
  2206. }
  2207. if (query_max_response_time >= pim_ifp->igmp_default_query_interval) {
  2208. vty_out(vty,
  2209. "Can't set query max response time %d sec >= general query interval %d sec%s",
  2210. query_max_response_time, pim_ifp->igmp_default_query_interval,
  2211. VTY_NEWLINE);
  2212. return CMD_WARNING;
  2213. }
  2214. change_query_max_response_time(pim_ifp, 10 * query_max_response_time);
  2215. return CMD_SUCCESS;
  2216. }
  2217. DEFUN (interface_no_ip_igmp_query_max_response_time,
  2218. interface_no_ip_igmp_query_max_response_time_cmd,
  2219. PIM_CMD_NO " " PIM_CMD_IP_IGMP_QUERY_MAX_RESPONSE_TIME,
  2220. NO_STR
  2221. IP_STR
  2222. IFACE_IGMP_STR
  2223. IFACE_IGMP_QUERY_MAX_RESPONSE_TIME_STR)
  2224. {
  2225. struct interface *ifp;
  2226. struct pim_interface *pim_ifp;
  2227. int default_query_interval_dsec;
  2228. ifp = vty->index;
  2229. pim_ifp = ifp->info;
  2230. if (!pim_ifp)
  2231. return CMD_SUCCESS;
  2232. default_query_interval_dsec = 10 * pim_ifp->igmp_default_query_interval;
  2233. if (IGMP_QUERY_MAX_RESPONSE_TIME_DSEC >= default_query_interval_dsec) {
  2234. vty_out(vty,
  2235. "Can't set default query max response time %d dsec >= general query interval %d dsec.%s",
  2236. IGMP_QUERY_MAX_RESPONSE_TIME_DSEC, default_query_interval_dsec,
  2237. VTY_NEWLINE);
  2238. return CMD_WARNING;
  2239. }
  2240. change_query_max_response_time(pim_ifp, IGMP_QUERY_MAX_RESPONSE_TIME_DSEC);
  2241. return CMD_SUCCESS;
  2242. }
  2243. #define IGMP_QUERY_MAX_RESPONSE_TIME_MIN_DSEC (10)
  2244. #define IGMP_QUERY_MAX_RESPONSE_TIME_MAX_DSEC (250)
  2245. DEFUN (interface_ip_igmp_query_max_response_time_dsec,
  2246. interface_ip_igmp_query_max_response_time_dsec_cmd,
  2247. PIM_CMD_IP_IGMP_QUERY_MAX_RESPONSE_TIME_DSEC " <10-250>",
  2248. IP_STR
  2249. IFACE_IGMP_STR
  2250. IFACE_IGMP_QUERY_MAX_RESPONSE_TIME_DSEC_STR
  2251. "Query response value in deciseconds\n")
  2252. {
  2253. struct interface *ifp;
  2254. struct pim_interface *pim_ifp;
  2255. int query_max_response_time_dsec;
  2256. int default_query_interval_dsec;
  2257. ifp = vty->index;
  2258. pim_ifp = ifp->info;
  2259. if (!pim_ifp) {
  2260. vty_out(vty,
  2261. "IGMP not enabled on interface %s. Please enable IGMP first.%s",
  2262. ifp->name,
  2263. VTY_NEWLINE);
  2264. return CMD_WARNING;
  2265. }
  2266. query_max_response_time_dsec = atoi(argv[0]);
  2267. /*
  2268. It seems we don't need to check bounds since command.c does it
  2269. already, but we verify them anyway for extra safety.
  2270. */
  2271. if (query_max_response_time_dsec < IGMP_QUERY_MAX_RESPONSE_TIME_MIN_DSEC) {
  2272. vty_out(vty, "Query max response time %d dsec lower than minimum %d dsec%s",
  2273. query_max_response_time_dsec,
  2274. IGMP_QUERY_MAX_RESPONSE_TIME_MIN_DSEC,
  2275. VTY_NEWLINE);
  2276. return CMD_WARNING;
  2277. }
  2278. if (query_max_response_time_dsec > IGMP_QUERY_MAX_RESPONSE_TIME_MAX_DSEC) {
  2279. vty_out(vty, "Query max response time %d dsec higher than maximum %d dsec%s",
  2280. query_max_response_time_dsec,
  2281. IGMP_QUERY_MAX_RESPONSE_TIME_MAX_DSEC,
  2282. VTY_NEWLINE);
  2283. return CMD_WARNING;
  2284. }
  2285. default_query_interval_dsec = 10 * pim_ifp->igmp_default_query_interval;
  2286. if (query_max_response_time_dsec >= default_query_interval_dsec) {
  2287. vty_out(vty,
  2288. "Can't set query max response time %d dsec >= general query interval %d dsec%s",
  2289. query_max_response_time_dsec, default_query_interval_dsec,
  2290. VTY_NEWLINE);
  2291. return CMD_WARNING;
  2292. }
  2293. change_query_max_response_time(pim_ifp, query_max_response_time_dsec);
  2294. return CMD_SUCCESS;
  2295. }
  2296. DEFUN (interface_no_ip_igmp_query_max_response_time_dsec,
  2297. interface_no_ip_igmp_query_max_response_time_dsec_cmd,
  2298. PIM_CMD_NO " " PIM_CMD_IP_IGMP_QUERY_MAX_RESPONSE_TIME_DSEC,
  2299. NO_STR
  2300. IP_STR
  2301. IFACE_IGMP_STR
  2302. IFACE_IGMP_QUERY_MAX_RESPONSE_TIME_DSEC_STR)
  2303. {
  2304. struct interface *ifp;
  2305. struct pim_interface *pim_ifp;
  2306. int default_query_interval_dsec;
  2307. ifp = vty->index;
  2308. pim_ifp = ifp->info;
  2309. if (!pim_ifp)
  2310. return CMD_SUCCESS;
  2311. default_query_interval_dsec = 10 * pim_ifp->igmp_default_query_interval;
  2312. if (IGMP_QUERY_MAX_RESPONSE_TIME_DSEC >= default_query_interval_dsec) {
  2313. vty_out(vty,
  2314. "Can't set default query max response time %d dsec >= general query interval %d dsec.%s",
  2315. IGMP_QUERY_MAX_RESPONSE_TIME_DSEC, default_query_interval_dsec,
  2316. VTY_NEWLINE);
  2317. return CMD_WARNING;
  2318. }
  2319. change_query_max_response_time(pim_ifp, IGMP_QUERY_MAX_RESPONSE_TIME_DSEC);
  2320. return CMD_SUCCESS;
  2321. }
  2322. DEFUN (interface_ip_pim_ssm,
  2323. interface_ip_pim_ssm_cmd,
  2324. "ip pim ssm",
  2325. IP_STR
  2326. PIM_STR
  2327. IFACE_PIM_STR)
  2328. {
  2329. struct interface *ifp;
  2330. struct pim_interface *pim_ifp;
  2331. ifp = vty->index;
  2332. pim_ifp = ifp->info;
  2333. if (!pim_ifp) {
  2334. pim_ifp = pim_if_new(ifp, 0 /* igmp=false */, 1 /* pim=true */);
  2335. if (!pim_ifp) {
  2336. vty_out(vty, "Could not enable PIM on interface%s", VTY_NEWLINE);
  2337. return CMD_WARNING;
  2338. }
  2339. }
  2340. else {
  2341. PIM_IF_DO_PIM(pim_ifp->options);
  2342. }
  2343. pim_if_addr_add_all(ifp);
  2344. pim_if_membership_refresh(ifp);
  2345. return CMD_SUCCESS;
  2346. }
  2347. DEFUN (interface_no_ip_pim_ssm,
  2348. interface_no_ip_pim_ssm_cmd,
  2349. "no ip pim ssm",
  2350. NO_STR
  2351. IP_STR
  2352. PIM_STR
  2353. IFACE_PIM_STR)
  2354. {
  2355. struct interface *ifp;
  2356. struct pim_interface *pim_ifp;
  2357. ifp = vty->index;
  2358. pim_ifp = ifp->info;
  2359. if (!pim_ifp)
  2360. return CMD_SUCCESS;
  2361. PIM_IF_DONT_PIM(pim_ifp->options);
  2362. pim_if_membership_clear(ifp);
  2363. /*
  2364. pim_if_addr_del_all() removes all sockets from
  2365. pim_ifp->igmp_socket_list.
  2366. */
  2367. pim_if_addr_del_all(ifp);
  2368. /*
  2369. pim_sock_delete() removes all neighbors from
  2370. pim_ifp->pim_neighbor_list.
  2371. */
  2372. pim_sock_delete(ifp, "pim unconfigured on interface");
  2373. if (!PIM_IF_TEST_IGMP(pim_ifp->options)) {
  2374. pim_if_delete(ifp);
  2375. }
  2376. return CMD_SUCCESS;
  2377. }
  2378. DEFUN (debug_igmp,
  2379. debug_igmp_cmd,
  2380. "debug igmp",
  2381. DEBUG_STR
  2382. DEBUG_IGMP_STR)
  2383. {
  2384. PIM_DO_DEBUG_IGMP_EVENTS;
  2385. PIM_DO_DEBUG_IGMP_PACKETS;
  2386. PIM_DO_DEBUG_IGMP_TRACE;
  2387. return CMD_SUCCESS;
  2388. }
  2389. DEFUN (no_debug_igmp,
  2390. no_debug_igmp_cmd,
  2391. "no debug igmp",
  2392. NO_STR
  2393. DEBUG_STR
  2394. DEBUG_IGMP_STR)
  2395. {
  2396. PIM_DONT_DEBUG_IGMP_EVENTS;
  2397. PIM_DONT_DEBUG_IGMP_PACKETS;
  2398. PIM_DONT_DEBUG_IGMP_TRACE;
  2399. return CMD_SUCCESS;
  2400. }
  2401. ALIAS (no_debug_igmp,
  2402. undebug_igmp_cmd,
  2403. "undebug igmp",
  2404. UNDEBUG_STR
  2405. DEBUG_IGMP_STR)
  2406. DEFUN (debug_igmp_events,
  2407. debug_igmp_events_cmd,
  2408. "debug igmp events",
  2409. DEBUG_STR
  2410. DEBUG_IGMP_STR
  2411. DEBUG_IGMP_EVENTS_STR)
  2412. {
  2413. PIM_DO_DEBUG_IGMP_EVENTS;
  2414. return CMD_SUCCESS;
  2415. }
  2416. DEFUN (no_debug_igmp_events,
  2417. no_debug_igmp_events_cmd,
  2418. "no debug igmp events",
  2419. NO_STR
  2420. DEBUG_STR
  2421. DEBUG_IGMP_STR
  2422. DEBUG_IGMP_EVENTS_STR)
  2423. {
  2424. PIM_DONT_DEBUG_IGMP_EVENTS;
  2425. return CMD_SUCCESS;
  2426. }
  2427. ALIAS (no_debug_igmp_events,
  2428. undebug_igmp_events_cmd,
  2429. "undebug igmp events",
  2430. UNDEBUG_STR
  2431. DEBUG_IGMP_STR
  2432. DEBUG_IGMP_EVENTS_STR)
  2433. DEFUN (debug_igmp_packets,
  2434. debug_igmp_packets_cmd,
  2435. "debug igmp packets",
  2436. DEBUG_STR
  2437. DEBUG_IGMP_STR
  2438. DEBUG_IGMP_PACKETS_STR)
  2439. {
  2440. PIM_DO_DEBUG_IGMP_PACKETS;
  2441. return CMD_SUCCESS;
  2442. }
  2443. DEFUN (no_debug_igmp_packets,
  2444. no_debug_igmp_packets_cmd,
  2445. "no debug igmp packets",
  2446. NO_STR
  2447. DEBUG_STR
  2448. DEBUG_IGMP_STR
  2449. DEBUG_IGMP_PACKETS_STR)
  2450. {
  2451. PIM_DONT_DEBUG_IGMP_PACKETS;
  2452. return CMD_SUCCESS;
  2453. }
  2454. ALIAS (no_debug_igmp_packets,
  2455. undebug_igmp_packets_cmd,
  2456. "undebug igmp packets",
  2457. UNDEBUG_STR
  2458. DEBUG_IGMP_STR
  2459. DEBUG_IGMP_PACKETS_STR)
  2460. DEFUN (debug_igmp_trace,
  2461. debug_igmp_trace_cmd,
  2462. "debug igmp trace",
  2463. DEBUG_STR
  2464. DEBUG_IGMP_STR
  2465. DEBUG_IGMP_TRACE_STR)
  2466. {
  2467. PIM_DO_DEBUG_IGMP_TRACE;
  2468. return CMD_SUCCESS;
  2469. }
  2470. DEFUN (no_debug_igmp_trace,
  2471. no_debug_igmp_trace_cmd,
  2472. "no debug igmp trace",
  2473. NO_STR
  2474. DEBUG_STR
  2475. DEBUG_IGMP_STR
  2476. DEBUG_IGMP_TRACE_STR)
  2477. {
  2478. PIM_DONT_DEBUG_IGMP_TRACE;
  2479. return CMD_SUCCESS;
  2480. }
  2481. ALIAS (no_debug_igmp_trace,
  2482. undebug_igmp_trace_cmd,
  2483. "undebug igmp trace",
  2484. UNDEBUG_STR
  2485. DEBUG_IGMP_STR
  2486. DEBUG_IGMP_TRACE_STR)
  2487. DEFUN (debug_pim,
  2488. debug_pim_cmd,
  2489. "debug pim",
  2490. DEBUG_STR
  2491. DEBUG_PIM_STR)
  2492. {
  2493. PIM_DO_DEBUG_PIM_EVENTS;
  2494. PIM_DO_DEBUG_PIM_PACKETS;
  2495. PIM_DO_DEBUG_PIM_TRACE;
  2496. return CMD_SUCCESS;
  2497. }
  2498. DEFUN (no_debug_pim,
  2499. no_debug_pim_cmd,
  2500. "no debug pim",
  2501. NO_STR
  2502. DEBUG_STR
  2503. DEBUG_PIM_STR)
  2504. {
  2505. PIM_DONT_DEBUG_PIM_EVENTS;
  2506. PIM_DONT_DEBUG_PIM_PACKETS;
  2507. PIM_DONT_DEBUG_PIM_TRACE;
  2508. return CMD_SUCCESS;
  2509. }
  2510. ALIAS (no_debug_pim,
  2511. undebug_pim_cmd,
  2512. "undebug pim",
  2513. UNDEBUG_STR
  2514. DEBUG_PIM_STR)
  2515. DEFUN (debug_pim_events,
  2516. debug_pim_events_cmd,
  2517. "debug pim events",
  2518. DEBUG_STR
  2519. DEBUG_PIM_STR
  2520. DEBUG_PIM_EVENTS_STR)
  2521. {
  2522. PIM_DO_DEBUG_PIM_EVENTS;
  2523. return CMD_SUCCESS;
  2524. }
  2525. DEFUN (no_debug_pim_events,
  2526. no_debug_pim_events_cmd,
  2527. "no debug pim events",
  2528. NO_STR
  2529. DEBUG_STR
  2530. DEBUG_PIM_STR
  2531. DEBUG_PIM_EVENTS_STR)
  2532. {
  2533. PIM_DONT_DEBUG_PIM_EVENTS;
  2534. return CMD_SUCCESS;
  2535. }
  2536. ALIAS (no_debug_pim_events,
  2537. undebug_pim_events_cmd,
  2538. "undebug pim events",
  2539. UNDEBUG_STR
  2540. DEBUG_PIM_STR
  2541. DEBUG_PIM_EVENTS_STR)
  2542. DEFUN (debug_pim_packets,
  2543. debug_pim_packets_cmd,
  2544. "debug pim packets",
  2545. DEBUG_STR
  2546. DEBUG_PIM_STR
  2547. DEBUG_PIM_PACKETS_STR)
  2548. {
  2549. PIM_DO_DEBUG_PIM_PACKETS;
  2550. return CMD_SUCCESS;
  2551. }
  2552. DEFUN (no_debug_pim_packets,
  2553. no_debug_pim_packets_cmd,
  2554. "no debug pim packets",
  2555. NO_STR
  2556. DEBUG_STR
  2557. DEBUG_PIM_STR
  2558. DEBUG_PIM_PACKETS_STR)
  2559. {
  2560. PIM_DONT_DEBUG_PIM_PACKETS;
  2561. return CMD_SUCCESS;
  2562. }
  2563. ALIAS (no_debug_pim_packets,
  2564. undebug_pim_packets_cmd,
  2565. "undebug pim packets",
  2566. UNDEBUG_STR
  2567. DEBUG_PIM_STR
  2568. DEBUG_PIM_PACKETS_STR)
  2569. DEFUN (debug_pim_trace,
  2570. debug_pim_trace_cmd,
  2571. "debug pim trace",
  2572. DEBUG_STR
  2573. DEBUG_PIM_STR
  2574. DEBUG_PIM_TRACE_STR)
  2575. {
  2576. PIM_DO_DEBUG_PIM_TRACE;
  2577. return CMD_SUCCESS;
  2578. }
  2579. DEFUN (no_debug_pim_trace,
  2580. no_debug_pim_trace_cmd,
  2581. "no debug pim trace",
  2582. NO_STR
  2583. DEBUG_STR
  2584. DEBUG_PIM_STR
  2585. DEBUG_PIM_TRACE_STR)
  2586. {
  2587. PIM_DONT_DEBUG_PIM_TRACE;
  2588. return CMD_SUCCESS;
  2589. }
  2590. ALIAS (no_debug_pim_trace,
  2591. undebug_pim_trace_cmd,
  2592. "undebug pim trace",
  2593. UNDEBUG_STR
  2594. DEBUG_PIM_STR
  2595. DEBUG_PIM_TRACE_STR)
  2596. DEFUN (debug_ssmpingd,
  2597. debug_ssmpingd_cmd,
  2598. "debug ssmpingd",
  2599. DEBUG_STR
  2600. DEBUG_PIM_STR
  2601. DEBUG_SSMPINGD_STR)
  2602. {
  2603. PIM_DO_DEBUG_SSMPINGD;
  2604. return CMD_SUCCESS;
  2605. }
  2606. DEFUN (no_debug_ssmpingd,
  2607. no_debug_ssmpingd_cmd,
  2608. "no debug ssmpingd",
  2609. NO_STR
  2610. DEBUG_STR
  2611. DEBUG_PIM_STR
  2612. DEBUG_SSMPINGD_STR)
  2613. {
  2614. PIM_DONT_DEBUG_SSMPINGD;
  2615. return CMD_SUCCESS;
  2616. }
  2617. ALIAS (no_debug_ssmpingd,
  2618. undebug_ssmpingd_cmd,
  2619. "undebug ssmpingd",
  2620. UNDEBUG_STR
  2621. DEBUG_PIM_STR
  2622. DEBUG_SSMPINGD_STR)
  2623. DEFUN (debug_pim_zebra,
  2624. debug_pim_zebra_cmd,
  2625. "debug pim zebra",
  2626. DEBUG_STR
  2627. DEBUG_PIM_STR
  2628. DEBUG_PIM_ZEBRA_STR)
  2629. {
  2630. PIM_DO_DEBUG_ZEBRA;
  2631. return CMD_SUCCESS;
  2632. }
  2633. DEFUN (no_debug_pim_zebra,
  2634. no_debug_pim_zebra_cmd,
  2635. "no debug pim zebra",
  2636. NO_STR
  2637. DEBUG_STR
  2638. DEBUG_PIM_STR
  2639. DEBUG_PIM_ZEBRA_STR)
  2640. {
  2641. PIM_DONT_DEBUG_ZEBRA;
  2642. return CMD_SUCCESS;
  2643. }
  2644. ALIAS (no_debug_pim_zebra,
  2645. undebug_pim_zebra_cmd,
  2646. "undebug pim zebra",
  2647. UNDEBUG_STR
  2648. DEBUG_PIM_STR
  2649. DEBUG_PIM_ZEBRA_STR)
  2650. DEFUN (show_debugging,
  2651. show_debugging_cmd,
  2652. "show debugging",
  2653. SHOW_STR
  2654. "State of each debugging option\n")
  2655. {
  2656. pim_debug_config_write(vty);
  2657. return CMD_SUCCESS;
  2658. }
  2659. static struct igmp_sock *find_igmp_sock_by_fd(int fd)
  2660. {
  2661. struct listnode *ifnode;
  2662. struct interface *ifp;
  2663. /* scan all interfaces */
  2664. for (ALL_LIST_ELEMENTS_RO(iflist, ifnode, ifp)) {
  2665. struct pim_interface *pim_ifp;
  2666. struct igmp_sock *igmp;
  2667. if (!ifp->info)
  2668. continue;
  2669. pim_ifp = ifp->info;
  2670. /* lookup igmp socket under current interface */
  2671. igmp = igmp_sock_lookup_by_fd(pim_ifp->igmp_socket_list, fd);
  2672. if (igmp)
  2673. return igmp;
  2674. }
  2675. return 0;
  2676. }
  2677. DEFUN (test_igmp_receive_report,
  2678. test_igmp_receive_report_cmd,
  2679. "test igmp receive report <0-65535> A.B.C.D <1-6> .LINE",
  2680. "Test\n"
  2681. "Test IGMP protocol\n"
  2682. "Test IGMP message\n"
  2683. "Test IGMP report\n"
  2684. "Socket\n"
  2685. "IGMP group address\n"
  2686. "Record type\n"
  2687. "Sources\n")
  2688. {
  2689. char buf[1000];
  2690. char *igmp_msg;
  2691. struct ip *ip_hdr;
  2692. size_t ip_hlen; /* ip header length in bytes */
  2693. int ip_msg_len;
  2694. int igmp_msg_len;
  2695. const char *socket;
  2696. int socket_fd;
  2697. const char *grp_str;
  2698. struct in_addr grp_addr;
  2699. const char *record_type_str;
  2700. int record_type;
  2701. const char *src_str;
  2702. int result;
  2703. struct igmp_sock *igmp;
  2704. char *group_record;
  2705. int num_sources;
  2706. struct in_addr *sources;
  2707. struct in_addr *src_addr;
  2708. int argi;
  2709. socket = argv[0];
  2710. socket_fd = atoi(socket);
  2711. igmp = find_igmp_sock_by_fd(socket_fd);
  2712. if (!igmp) {
  2713. vty_out(vty, "Could not find IGMP socket %s: fd=%d%s",
  2714. socket, socket_fd, VTY_NEWLINE);
  2715. return CMD_WARNING;
  2716. }
  2717. grp_str = argv[1];
  2718. result = inet_pton(AF_INET, grp_str, &grp_addr);
  2719. if (result <= 0) {
  2720. vty_out(vty, "Bad group address %s: errno=%d: %s%s",
  2721. grp_str, errno, safe_strerror(errno), VTY_NEWLINE);
  2722. return CMD_WARNING;
  2723. }
  2724. record_type_str = argv[2];
  2725. record_type = atoi(record_type_str);
  2726. /*
  2727. Tweak IP header
  2728. */
  2729. ip_hdr = (struct ip *) buf;
  2730. ip_hdr->ip_p = PIM_IP_PROTO_IGMP;
  2731. ip_hlen = PIM_IP_HEADER_MIN_LEN; /* ip header length in bytes */
  2732. ip_hdr->ip_hl = ip_hlen >> 2; /* ip header length in 4-byte words */
  2733. ip_hdr->ip_src = igmp->ifaddr;
  2734. ip_hdr->ip_dst = igmp->ifaddr;
  2735. /*
  2736. Build IGMP v3 report message
  2737. */
  2738. igmp_msg = buf + ip_hlen;
  2739. group_record = igmp_msg + IGMP_V3_REPORT_GROUPPRECORD_OFFSET;
  2740. *igmp_msg = PIM_IGMP_V3_MEMBERSHIP_REPORT; /* type */
  2741. *(uint16_t *) (igmp_msg + IGMP_V3_CHECKSUM_OFFSET) = 0; /* for computing checksum */
  2742. *(uint16_t *) (igmp_msg + IGMP_V3_REPORT_NUMGROUPS_OFFSET) = htons(1); /* one group record */
  2743. *(uint8_t *) (group_record + IGMP_V3_GROUP_RECORD_TYPE_OFFSET) = record_type;
  2744. *(struct in_addr *)(group_record + IGMP_V3_GROUP_RECORD_GROUP_OFFSET) = grp_addr;
  2745. /* Scan LINE sources */
  2746. sources = (struct in_addr *) (group_record + IGMP_V3_GROUP_RECORD_SOURCE_OFFSET);
  2747. src_addr = sources;
  2748. for (argi = 3; argi < argc; ++argi,++src_addr) {
  2749. src_str = argv[argi];
  2750. result = inet_pton(AF_INET, src_str, src_addr);
  2751. if (result <= 0) {
  2752. vty_out(vty, "Bad source address %s: errno=%d: %s%s",
  2753. src_str, errno, safe_strerror(errno), VTY_NEWLINE);
  2754. return CMD_WARNING;
  2755. }
  2756. }
  2757. num_sources = src_addr - sources;
  2758. *(uint16_t *)(group_record + IGMP_V3_GROUP_RECORD_NUMSOURCES_OFFSET) = htons(num_sources);
  2759. igmp_msg_len = IGMP_V3_MSG_MIN_SIZE + (num_sources << 4); /* v3 report for one single group record */
  2760. /* compute checksum */
  2761. *(uint16_t *)(igmp_msg + IGMP_V3_CHECKSUM_OFFSET) = pim_inet_checksum(igmp_msg, igmp_msg_len);
  2762. /* "receive" message */
  2763. ip_msg_len = ip_hlen + igmp_msg_len;
  2764. result = pim_igmp_packet(igmp, buf, ip_msg_len);
  2765. if (result) {
  2766. vty_out(vty, "pim_igmp_packet(len=%d) returned: %d%s",
  2767. ip_msg_len, result, VTY_NEWLINE);
  2768. return CMD_WARNING;
  2769. }
  2770. return CMD_SUCCESS;
  2771. }
  2772. DEFUN (test_pim_receive_hello,
  2773. test_pim_receive_hello_cmd,
  2774. "test pim receive hello INTERFACE A.B.C.D <0-65535> <0-65535> <0-65535> <0-32767> <0-65535> <0-1>[LINE]",
  2775. "Test\n"
  2776. "Test PIM protocol\n"
  2777. "Test PIM message reception\n"
  2778. "Test PIM hello reception from neighbor\n"
  2779. "Interface\n"
  2780. "Neighbor address\n"
  2781. "Neighbor holdtime\n"
  2782. "Neighbor DR priority\n"
  2783. "Neighbor generation ID\n"
  2784. "Neighbor propagation delay (msec)\n"
  2785. "Neighbor override interval (msec)\n"
  2786. "Neighbor LAN prune delay T-bit\n"
  2787. "Neighbor secondary addresses\n")
  2788. {
  2789. char buf[1000];
  2790. char *pim_msg;
  2791. struct ip *ip_hdr;
  2792. size_t ip_hlen; /* ip header length in bytes */
  2793. int ip_msg_len;
  2794. int pim_tlv_size;
  2795. int pim_msg_size;
  2796. const char *neigh_str;
  2797. struct in_addr neigh_addr;
  2798. const char *ifname;
  2799. struct interface *ifp;
  2800. uint16_t neigh_holdtime;
  2801. uint16_t neigh_propagation_delay;
  2802. uint16_t neigh_override_interval;
  2803. int neigh_can_disable_join_suppression;
  2804. uint32_t neigh_dr_priority;
  2805. uint32_t neigh_generation_id;
  2806. int argi;
  2807. int result;
  2808. /* Find interface */
  2809. ifname = argv[0];
  2810. ifp = if_lookup_by_name(ifname);
  2811. if (!ifp) {
  2812. vty_out(vty, "No such interface name %s%s",
  2813. ifname, VTY_NEWLINE);
  2814. return CMD_WARNING;
  2815. }
  2816. /* Neighbor address */
  2817. neigh_str = argv[1];
  2818. result = inet_pton(AF_INET, neigh_str, &neigh_addr);
  2819. if (result <= 0) {
  2820. vty_out(vty, "Bad neighbor address %s: errno=%d: %s%s",
  2821. neigh_str, errno, safe_strerror(errno), VTY_NEWLINE);
  2822. return CMD_WARNING;
  2823. }
  2824. neigh_holdtime = atoi(argv[2]);
  2825. neigh_dr_priority = atoi(argv[3]);
  2826. neigh_generation_id = atoi(argv[4]);
  2827. neigh_propagation_delay = atoi(argv[5]);
  2828. neigh_override_interval = atoi(argv[6]);
  2829. neigh_can_disable_join_suppression = atoi(argv[7]);
  2830. /*
  2831. Tweak IP header
  2832. */
  2833. ip_hdr = (struct ip *) buf;
  2834. ip_hdr->ip_p = PIM_IP_PROTO_PIM;
  2835. ip_hlen = PIM_IP_HEADER_MIN_LEN; /* ip header length in bytes */
  2836. ip_hdr->ip_hl = ip_hlen >> 2; /* ip header length in 4-byte words */
  2837. ip_hdr->ip_src = neigh_addr;
  2838. ip_hdr->ip_dst = qpim_all_pim_routers_addr;
  2839. /*
  2840. Build PIM hello message
  2841. */
  2842. pim_msg = buf + ip_hlen;
  2843. /* Scan LINE addresses */
  2844. for (argi = 8; argi < argc; ++argi) {
  2845. const char *sec_str = argv[argi];
  2846. struct in_addr sec_addr;
  2847. result = inet_pton(AF_INET, sec_str, &sec_addr);
  2848. if (result <= 0) {
  2849. vty_out(vty, "Bad neighbor secondary address %s: errno=%d: %s%s",
  2850. sec_str, errno, safe_strerror(errno), VTY_NEWLINE);
  2851. return CMD_WARNING;
  2852. }
  2853. vty_out(vty,
  2854. "FIXME WRITEME consider neighbor secondary address %s%s",
  2855. sec_str, VTY_NEWLINE);
  2856. }
  2857. pim_tlv_size = pim_hello_build_tlv(ifp->name,
  2858. pim_msg + PIM_PIM_MIN_LEN,
  2859. sizeof(buf) - ip_hlen - PIM_PIM_MIN_LEN,
  2860. neigh_holdtime,
  2861. neigh_dr_priority,
  2862. neigh_generation_id,
  2863. neigh_propagation_delay,
  2864. neigh_override_interval,
  2865. neigh_can_disable_join_suppression,
  2866. 0 /* FIXME secondary address list */);
  2867. if (pim_tlv_size < 0) {
  2868. vty_out(vty, "pim_hello_build_tlv() returned failure: %d%s",
  2869. pim_tlv_size, VTY_NEWLINE);
  2870. return CMD_WARNING;
  2871. }
  2872. pim_msg_size = pim_tlv_size + PIM_PIM_MIN_LEN;
  2873. pim_msg_build_header(pim_msg, pim_msg_size,
  2874. PIM_MSG_TYPE_HELLO);
  2875. /* "receive" message */
  2876. ip_msg_len = ip_hlen + pim_msg_size;
  2877. result = pim_pim_packet(ifp, buf, ip_msg_len);
  2878. if (result) {
  2879. vty_out(vty, "pim_pim_packet(len=%d) returned failure: %d%s",
  2880. ip_msg_len, result, VTY_NEWLINE);
  2881. return CMD_WARNING;
  2882. }
  2883. return CMD_SUCCESS;
  2884. }
  2885. DEFUN (test_pim_receive_assert,
  2886. test_pim_receive_assert_cmd,
  2887. "test pim receive assert INTERFACE A.B.C.D A.B.C.D A.B.C.D <0-65535> <0-65535> <0-1>",
  2888. "Test\n"
  2889. "Test PIM protocol\n"
  2890. "Test PIM message reception\n"
  2891. "Test reception of PIM assert\n"
  2892. "Interface\n"
  2893. "Neighbor address\n"
  2894. "Assert multicast group address\n"
  2895. "Assert unicast source address\n"
  2896. "Assert metric preference\n"
  2897. "Assert route metric\n"
  2898. "Assert RPT bit flag\n")
  2899. {
  2900. char buf[1000];
  2901. char *buf_pastend = buf + sizeof(buf);
  2902. char *pim_msg;
  2903. struct ip *ip_hdr;
  2904. size_t ip_hlen; /* ip header length in bytes */
  2905. int ip_msg_len;
  2906. int pim_msg_size;
  2907. const char *neigh_str;
  2908. struct in_addr neigh_addr;
  2909. const char *group_str;
  2910. struct in_addr group_addr;
  2911. const char *source_str;
  2912. struct in_addr source_addr;
  2913. const char *ifname;
  2914. struct interface *ifp;
  2915. uint32_t assert_metric_preference;
  2916. uint32_t assert_route_metric;
  2917. uint32_t assert_rpt_bit_flag;
  2918. int remain;
  2919. int result;
  2920. /* Find interface */
  2921. ifname = argv[0];
  2922. ifp = if_lookup_by_name(ifname);
  2923. if (!ifp) {
  2924. vty_out(vty, "No such interface name %s%s",
  2925. ifname, VTY_NEWLINE);
  2926. return CMD_WARNING;
  2927. }
  2928. /* Neighbor address */
  2929. neigh_str = argv[1];
  2930. result = inet_pton(AF_INET, neigh_str, &neigh_addr);
  2931. if (result <= 0) {
  2932. vty_out(vty, "Bad neighbor address %s: errno=%d: %s%s",
  2933. neigh_str, errno, safe_strerror(errno), VTY_NEWLINE);
  2934. return CMD_WARNING;
  2935. }
  2936. /* Group address */
  2937. group_str = argv[2];
  2938. result = inet_pton(AF_INET, group_str, &group_addr);
  2939. if (result <= 0) {
  2940. vty_out(vty, "Bad group address %s: errno=%d: %s%s",
  2941. group_str, errno, safe_strerror(errno), VTY_NEWLINE);
  2942. return CMD_WARNING;
  2943. }
  2944. /* Source address */
  2945. source_str = argv[3];
  2946. result = inet_pton(AF_INET, source_str, &source_addr);
  2947. if (result <= 0) {
  2948. vty_out(vty, "Bad source address %s: errno=%d: %s%s",
  2949. source_str, errno, safe_strerror(errno), VTY_NEWLINE);
  2950. return CMD_WARNING;
  2951. }
  2952. assert_metric_preference = atoi(argv[4]);
  2953. assert_route_metric = atoi(argv[5]);
  2954. assert_rpt_bit_flag = atoi(argv[6]);
  2955. remain = buf_pastend - buf;
  2956. if (remain < (int) sizeof(struct ip)) {
  2957. vty_out(vty, "No room for ip header: buf_size=%d < ip_header_size=%d%s",
  2958. remain, sizeof(struct ip), VTY_NEWLINE);
  2959. return CMD_WARNING;
  2960. }
  2961. /*
  2962. Tweak IP header
  2963. */
  2964. ip_hdr = (struct ip *) buf;
  2965. ip_hdr->ip_p = PIM_IP_PROTO_PIM;
  2966. ip_hlen = PIM_IP_HEADER_MIN_LEN; /* ip header length in bytes */
  2967. ip_hdr->ip_hl = ip_hlen >> 2; /* ip header length in 4-byte words */
  2968. ip_hdr->ip_src = neigh_addr;
  2969. ip_hdr->ip_dst = qpim_all_pim_routers_addr;
  2970. /*
  2971. Build PIM assert message
  2972. */
  2973. pim_msg = buf + ip_hlen; /* skip ip header */
  2974. pim_msg_size = pim_assert_build_msg(pim_msg, buf_pastend - pim_msg, ifp,
  2975. group_addr, source_addr,
  2976. assert_metric_preference,
  2977. assert_route_metric,
  2978. assert_rpt_bit_flag);
  2979. if (pim_msg_size < 0) {
  2980. vty_out(vty, "Failure building PIM assert message: size=%d%s",
  2981. pim_msg_size, VTY_NEWLINE);
  2982. return CMD_WARNING;
  2983. }
  2984. /* "receive" message */
  2985. ip_msg_len = ip_hlen + pim_msg_size;
  2986. result = pim_pim_packet(ifp, buf, ip_msg_len);
  2987. if (result) {
  2988. vty_out(vty, "pim_pim_packet(len=%d) returned failure: %d%s",
  2989. ip_msg_len, result, VTY_NEWLINE);
  2990. return CMD_WARNING;
  2991. }
  2992. return CMD_SUCCESS;
  2993. }
  2994. static int recv_joinprune(struct vty *vty,
  2995. const char *argv[],
  2996. int src_is_join)
  2997. {
  2998. char buf[1000];
  2999. const char *buf_pastend = buf + sizeof(buf);
  3000. char *pim_msg;
  3001. char *pim_msg_curr;
  3002. int pim_msg_size;
  3003. struct ip *ip_hdr;
  3004. size_t ip_hlen; /* ip header length in bytes */
  3005. int ip_msg_len;
  3006. uint16_t neigh_holdtime;
  3007. const char *neigh_dst_str;
  3008. struct in_addr neigh_dst_addr;
  3009. const char *neigh_src_str;
  3010. struct in_addr neigh_src_addr;
  3011. const char *group_str;
  3012. struct in_addr group_addr;
  3013. const char *source_str;
  3014. struct in_addr source_addr;
  3015. const char *ifname;
  3016. struct interface *ifp;
  3017. int result;
  3018. int remain;
  3019. uint16_t num_joined;
  3020. uint16_t num_pruned;
  3021. /* Find interface */
  3022. ifname = argv[0];
  3023. ifp = if_lookup_by_name(ifname);
  3024. if (!ifp) {
  3025. vty_out(vty, "No such interface name %s%s",
  3026. ifname, VTY_NEWLINE);
  3027. return CMD_WARNING;
  3028. }
  3029. neigh_holdtime = atoi(argv[1]);
  3030. /* Neighbor destination address */
  3031. neigh_dst_str = argv[2];
  3032. result = inet_pton(AF_INET, neigh_dst_str, &neigh_dst_addr);
  3033. if (result <= 0) {
  3034. vty_out(vty, "Bad neighbor destination address %s: errno=%d: %s%s",
  3035. neigh_dst_str, errno, safe_strerror(errno), VTY_NEWLINE);
  3036. return CMD_WARNING;
  3037. }
  3038. /* Neighbor source address */
  3039. neigh_src_str = argv[3];
  3040. result = inet_pton(AF_INET, neigh_src_str, &neigh_src_addr);
  3041. if (result <= 0) {
  3042. vty_out(vty, "Bad neighbor source address %s: errno=%d: %s%s",
  3043. neigh_src_str, errno, safe_strerror(errno), VTY_NEWLINE);
  3044. return CMD_WARNING;
  3045. }
  3046. /* Multicast group address */
  3047. group_str = argv[4];
  3048. result = inet_pton(AF_INET, group_str, &group_addr);
  3049. if (result <= 0) {
  3050. vty_out(vty, "Bad group address %s: errno=%d: %s%s",
  3051. group_str, errno, safe_strerror(errno), VTY_NEWLINE);
  3052. return CMD_WARNING;
  3053. }
  3054. /* Multicast source address */
  3055. source_str = argv[5];
  3056. result = inet_pton(AF_INET, source_str, &source_addr);
  3057. if (result <= 0) {
  3058. vty_out(vty, "Bad source address %s: errno=%d: %s%s",
  3059. source_str, errno, safe_strerror(errno), VTY_NEWLINE);
  3060. return CMD_WARNING;
  3061. }
  3062. /*
  3063. Tweak IP header
  3064. */
  3065. ip_hdr = (struct ip *) buf;
  3066. ip_hdr->ip_p = PIM_IP_PROTO_PIM;
  3067. ip_hlen = PIM_IP_HEADER_MIN_LEN; /* ip header length in bytes */
  3068. ip_hdr->ip_hl = ip_hlen >> 2; /* ip header length in 4-byte words */
  3069. ip_hdr->ip_src = neigh_src_addr;
  3070. ip_hdr->ip_dst = qpim_all_pim_routers_addr;
  3071. /*
  3072. Build PIM message
  3073. */
  3074. pim_msg = buf + ip_hlen;
  3075. /* skip room for pim header */
  3076. pim_msg_curr = pim_msg + PIM_MSG_HEADER_LEN;
  3077. remain = buf_pastend - pim_msg_curr;
  3078. pim_msg_curr = pim_msg_addr_encode_ipv4_ucast(pim_msg_curr,
  3079. remain,
  3080. neigh_dst_addr);
  3081. if (!pim_msg_curr) {
  3082. vty_out(vty, "Failure encoding destination address %s: space left=%d%s",
  3083. neigh_dst_str, remain, VTY_NEWLINE);
  3084. return CMD_WARNING;
  3085. }
  3086. remain = buf_pastend - pim_msg_curr;
  3087. if (remain < 4) {
  3088. vty_out(vty, "Group will not fit: space left=%d%s",
  3089. remain, VTY_NEWLINE);
  3090. return CMD_WARNING;
  3091. }
  3092. *pim_msg_curr = 0; /* reserved */
  3093. ++pim_msg_curr;
  3094. *pim_msg_curr = 1; /* number of groups */
  3095. ++pim_msg_curr;
  3096. *((uint16_t *) pim_msg_curr) = htons(neigh_holdtime);
  3097. ++pim_msg_curr;
  3098. ++pim_msg_curr;
  3099. remain = buf_pastend - pim_msg_curr;
  3100. pim_msg_curr = pim_msg_addr_encode_ipv4_group(pim_msg_curr,
  3101. remain,
  3102. group_addr);
  3103. if (!pim_msg_curr) {
  3104. vty_out(vty, "Failure encoding group address %s: space left=%d%s",
  3105. group_str, remain, VTY_NEWLINE);
  3106. return CMD_WARNING;
  3107. }
  3108. remain = buf_pastend - pim_msg_curr;
  3109. if (remain < 4) {
  3110. vty_out(vty, "Sources will not fit: space left=%d%s",
  3111. remain, VTY_NEWLINE);
  3112. return CMD_WARNING;
  3113. }
  3114. if (src_is_join) {
  3115. num_joined = 1;
  3116. num_pruned = 0;
  3117. }
  3118. else {
  3119. num_joined = 0;
  3120. num_pruned = 1;
  3121. }
  3122. /* number of joined sources */
  3123. *((uint16_t *) pim_msg_curr) = htons(num_joined);
  3124. ++pim_msg_curr;
  3125. ++pim_msg_curr;
  3126. /* number of pruned sources */
  3127. *((uint16_t *) pim_msg_curr) = htons(num_pruned);
  3128. ++pim_msg_curr;
  3129. ++pim_msg_curr;
  3130. remain = buf_pastend - pim_msg_curr;
  3131. pim_msg_curr = pim_msg_addr_encode_ipv4_source(pim_msg_curr,
  3132. remain,
  3133. source_addr);
  3134. if (!pim_msg_curr) {
  3135. vty_out(vty, "Failure encoding source address %s: space left=%d%s",
  3136. source_str, remain, VTY_NEWLINE);
  3137. return CMD_WARNING;
  3138. }
  3139. /* Add PIM header */
  3140. pim_msg_size = pim_msg_curr - pim_msg;
  3141. pim_msg_build_header(pim_msg, pim_msg_size,
  3142. PIM_MSG_TYPE_JOIN_PRUNE);
  3143. /*
  3144. "Receive" message
  3145. */
  3146. ip_msg_len = ip_hlen + pim_msg_size;
  3147. result = pim_pim_packet(ifp, buf, ip_msg_len);
  3148. if (result) {
  3149. vty_out(vty, "pim_pim_packet(len=%d) returned failure: %d%s",
  3150. ip_msg_len, result, VTY_NEWLINE);
  3151. return CMD_WARNING;
  3152. }
  3153. return CMD_SUCCESS;
  3154. }
  3155. DEFUN (test_pim_receive_join,
  3156. test_pim_receive_join_cmd,
  3157. "test pim receive join INTERFACE <0-65535> A.B.C.D A.B.C.D A.B.C.D A.B.C.D",
  3158. "Test\n"
  3159. "Test PIM protocol\n"
  3160. "Test PIM message reception\n"
  3161. "Test PIM join reception from neighbor\n"
  3162. "Interface\n"
  3163. "Neighbor holdtime\n"
  3164. "Upstream neighbor unicast destination address\n"
  3165. "Downstream neighbor unicast source address\n"
  3166. "Multicast group address\n"
  3167. "Unicast source address\n")
  3168. {
  3169. return recv_joinprune(vty, argv, 1 /* src_is_join=true */);
  3170. }
  3171. DEFUN (test_pim_receive_prune,
  3172. test_pim_receive_prune_cmd,
  3173. "test pim receive prune INTERFACE <0-65535> A.B.C.D A.B.C.D A.B.C.D A.B.C.D",
  3174. "Test\n"
  3175. "Test PIM protocol\n"
  3176. "Test PIM message reception\n"
  3177. "Test PIM prune reception from neighbor\n"
  3178. "Interface\n"
  3179. "Neighbor holdtime\n"
  3180. "Upstream neighbor unicast destination address\n"
  3181. "Downstream neighbor unicast source address\n"
  3182. "Multicast group address\n"
  3183. "Unicast source address\n")
  3184. {
  3185. return recv_joinprune(vty, argv, 0 /* src_is_join=false */);
  3186. }
  3187. DEFUN (test_pim_receive_upcall,
  3188. test_pim_receive_upcall_cmd,
  3189. "test pim receive upcall (nocache|wrongvif|wholepkt) <0-65535> A.B.C.D A.B.C.D",
  3190. "Test\n"
  3191. "Test PIM protocol\n"
  3192. "Test PIM message reception\n"
  3193. "Test reception of kernel upcall\n"
  3194. "NOCACHE kernel upcall\n"
  3195. "WRONGVIF kernel upcall\n"
  3196. "WHOLEPKT kernel upcall\n"
  3197. "Input interface vif index\n"
  3198. "Multicast group address\n"
  3199. "Multicast source address\n")
  3200. {
  3201. struct igmpmsg msg;
  3202. const char *upcall_type;
  3203. const char *group_str;
  3204. const char *source_str;
  3205. int result;
  3206. upcall_type = argv[0];
  3207. if (upcall_type[0] == 'n')
  3208. msg.im_msgtype = IGMPMSG_NOCACHE;
  3209. else if (upcall_type[1] == 'r')
  3210. msg.im_msgtype = IGMPMSG_WRONGVIF;
  3211. else if (upcall_type[1] == 'h')
  3212. msg.im_msgtype = IGMPMSG_WHOLEPKT;
  3213. else {
  3214. vty_out(vty, "Unknown kernel upcall type: %s%s",
  3215. upcall_type, VTY_NEWLINE);
  3216. return CMD_WARNING;
  3217. }
  3218. msg.im_vif = atoi(argv[1]);
  3219. /* Group address */
  3220. group_str = argv[2];
  3221. result = inet_pton(AF_INET, group_str, &msg.im_dst);
  3222. if (result <= 0) {
  3223. vty_out(vty, "Bad group address %s: errno=%d: %s%s",
  3224. group_str, errno, safe_strerror(errno), VTY_NEWLINE);
  3225. return CMD_WARNING;
  3226. }
  3227. /* Source address */
  3228. source_str = argv[3];
  3229. result = inet_pton(AF_INET, source_str, &msg.im_src);
  3230. if (result <= 0) {
  3231. vty_out(vty, "Bad source address %s: errno=%d: %s%s",
  3232. source_str, errno, safe_strerror(errno), VTY_NEWLINE);
  3233. return CMD_WARNING;
  3234. }
  3235. msg.im_mbz = 0; /* Must be zero */
  3236. result = pim_mroute_msg(-1, (char *) &msg, sizeof(msg));
  3237. if (result) {
  3238. vty_out(vty, "pim_mroute_msg(len=%d) returned failure: %d%s",
  3239. sizeof(msg), result, VTY_NEWLINE);
  3240. return CMD_WARNING;
  3241. }
  3242. return CMD_SUCCESS;
  3243. }
  3244. void pim_cmd_init()
  3245. {
  3246. install_node (&pim_global_node, pim_global_config_write); /* PIM_NODE */
  3247. install_node (&interface_node, pim_interface_config_write); /* INTERFACE_NODE */
  3248. install_element (CONFIG_NODE, &ip_multicast_routing_cmd);
  3249. install_element (CONFIG_NODE, &no_ip_multicast_routing_cmd);
  3250. install_element (CONFIG_NODE, &ip_ssmpingd_cmd);
  3251. install_element (CONFIG_NODE, &no_ip_ssmpingd_cmd);
  3252. #if 0
  3253. install_element (CONFIG_NODE, &interface_cmd); /* from if.h */
  3254. #else
  3255. install_element (CONFIG_NODE, &pim_interface_cmd);
  3256. #endif
  3257. install_element (CONFIG_NODE, &no_interface_cmd); /* from if.h */
  3258. install_default (INTERFACE_NODE);
  3259. install_element (INTERFACE_NODE, &interface_ip_igmp_cmd);
  3260. install_element (INTERFACE_NODE, &interface_no_ip_igmp_cmd);
  3261. install_element (INTERFACE_NODE, &interface_ip_igmp_join_cmd);
  3262. install_element (INTERFACE_NODE, &interface_no_ip_igmp_join_cmd);
  3263. install_element (INTERFACE_NODE, &interface_ip_igmp_query_interval_cmd);
  3264. install_element (INTERFACE_NODE, &interface_no_ip_igmp_query_interval_cmd);
  3265. install_element (INTERFACE_NODE, &interface_ip_igmp_query_max_response_time_cmd);
  3266. install_element (INTERFACE_NODE, &interface_no_ip_igmp_query_max_response_time_cmd);
  3267. install_element (INTERFACE_NODE, &interface_ip_igmp_query_max_response_time_dsec_cmd);
  3268. install_element (INTERFACE_NODE, &interface_no_ip_igmp_query_max_response_time_dsec_cmd);
  3269. install_element (INTERFACE_NODE, &interface_ip_pim_ssm_cmd);
  3270. install_element (INTERFACE_NODE, &interface_no_ip_pim_ssm_cmd);
  3271. install_element (VIEW_NODE, &show_ip_igmp_interface_cmd);
  3272. install_element (VIEW_NODE, &show_ip_igmp_parameters_cmd);
  3273. install_element (VIEW_NODE, &show_ip_igmp_groups_cmd);
  3274. install_element (VIEW_NODE, &show_ip_igmp_groups_retransmissions_cmd);
  3275. install_element (VIEW_NODE, &show_ip_igmp_sources_cmd);
  3276. install_element (VIEW_NODE, &show_ip_igmp_sources_retransmissions_cmd);
  3277. install_element (VIEW_NODE, &show_ip_igmp_querier_cmd);
  3278. install_element (VIEW_NODE, &show_ip_pim_assert_cmd);
  3279. install_element (VIEW_NODE, &show_ip_pim_assert_internal_cmd);
  3280. install_element (VIEW_NODE, &show_ip_pim_assert_metric_cmd);
  3281. install_element (VIEW_NODE, &show_ip_pim_assert_winner_metric_cmd);
  3282. install_element (VIEW_NODE, &show_ip_pim_dr_cmd);
  3283. install_element (VIEW_NODE, &show_ip_pim_hello_cmd);
  3284. install_element (VIEW_NODE, &show_ip_pim_interface_cmd);
  3285. install_element (VIEW_NODE, &show_ip_pim_join_cmd);
  3286. install_element (VIEW_NODE, &show_ip_pim_jp_override_interval_cmd);
  3287. install_element (VIEW_NODE, &show_ip_pim_lan_prune_delay_cmd);
  3288. install_element (VIEW_NODE, &show_ip_pim_local_membership_cmd);
  3289. install_element (VIEW_NODE, &show_ip_pim_neighbor_cmd);
  3290. install_element (VIEW_NODE, &show_ip_pim_rpf_cmd);
  3291. install_element (VIEW_NODE, &show_ip_pim_secondary_cmd);
  3292. install_element (VIEW_NODE, &show_ip_pim_upstream_cmd);
  3293. install_element (VIEW_NODE, &show_ip_pim_upstream_join_desired_cmd);
  3294. install_element (VIEW_NODE, &show_ip_pim_upstream_rpf_cmd);
  3295. install_element (VIEW_NODE, &show_ip_multicast_cmd);
  3296. install_element (VIEW_NODE, &show_ip_mroute_cmd);
  3297. install_element (VIEW_NODE, &show_ip_mroute_count_cmd);
  3298. install_element (VIEW_NODE, &show_ip_route_cmd);
  3299. install_element (VIEW_NODE, &show_ip_ssmpingd_cmd);
  3300. install_element (VIEW_NODE, &show_debugging_cmd);
  3301. install_element (ENABLE_NODE, &clear_ip_interfaces_cmd);
  3302. install_element (ENABLE_NODE, &clear_ip_igmp_interfaces_cmd);
  3303. install_element (ENABLE_NODE, &clear_ip_pim_interfaces_cmd);
  3304. install_element (ENABLE_NODE, &show_ip_igmp_interface_cmd);
  3305. install_element (ENABLE_NODE, &show_ip_igmp_parameters_cmd);
  3306. install_element (ENABLE_NODE, &show_ip_igmp_groups_cmd);
  3307. install_element (ENABLE_NODE, &show_ip_igmp_groups_retransmissions_cmd);
  3308. install_element (ENABLE_NODE, &show_ip_igmp_sources_cmd);
  3309. install_element (ENABLE_NODE, &show_ip_igmp_sources_retransmissions_cmd);
  3310. install_element (ENABLE_NODE, &show_ip_igmp_querier_cmd);
  3311. install_element (ENABLE_NODE, &show_ip_pim_address_cmd);
  3312. install_element (ENABLE_NODE, &show_ip_pim_assert_cmd);
  3313. install_element (ENABLE_NODE, &show_ip_pim_assert_internal_cmd);
  3314. install_element (ENABLE_NODE, &show_ip_pim_assert_metric_cmd);
  3315. install_element (ENABLE_NODE, &show_ip_pim_assert_winner_metric_cmd);
  3316. install_element (ENABLE_NODE, &show_ip_pim_dr_cmd);
  3317. install_element (ENABLE_NODE, &show_ip_pim_hello_cmd);
  3318. install_element (ENABLE_NODE, &show_ip_pim_interface_cmd);
  3319. install_element (ENABLE_NODE, &show_ip_pim_join_cmd);
  3320. install_element (ENABLE_NODE, &show_ip_pim_jp_override_interval_cmd);
  3321. install_element (ENABLE_NODE, &show_ip_pim_lan_prune_delay_cmd);
  3322. install_element (ENABLE_NODE, &show_ip_pim_local_membership_cmd);
  3323. install_element (ENABLE_NODE, &show_ip_pim_neighbor_cmd);
  3324. install_element (ENABLE_NODE, &show_ip_pim_rpf_cmd);
  3325. install_element (ENABLE_NODE, &show_ip_pim_secondary_cmd);
  3326. install_element (ENABLE_NODE, &show_ip_pim_upstream_cmd);
  3327. install_element (ENABLE_NODE, &show_ip_pim_upstream_join_desired_cmd);
  3328. install_element (ENABLE_NODE, &show_ip_pim_upstream_rpf_cmd);
  3329. install_element (ENABLE_NODE, &show_ip_multicast_cmd);
  3330. install_element (ENABLE_NODE, &show_ip_mroute_cmd);
  3331. install_element (ENABLE_NODE, &show_ip_mroute_count_cmd);
  3332. install_element (ENABLE_NODE, &show_ip_route_cmd);
  3333. install_element (ENABLE_NODE, &show_debugging_cmd);
  3334. install_element (ENABLE_NODE, &test_igmp_receive_report_cmd);
  3335. install_element (ENABLE_NODE, &test_pim_receive_assert_cmd);
  3336. install_element (ENABLE_NODE, &test_pim_receive_hello_cmd);
  3337. install_element (ENABLE_NODE, &test_pim_receive_join_cmd);
  3338. install_element (ENABLE_NODE, &test_pim_receive_prune_cmd);
  3339. install_element (ENABLE_NODE, &test_pim_receive_upcall_cmd);
  3340. install_element (ENABLE_NODE, &debug_igmp_cmd);
  3341. install_element (ENABLE_NODE, &no_debug_igmp_cmd);
  3342. install_element (ENABLE_NODE, &undebug_igmp_cmd);
  3343. install_element (ENABLE_NODE, &debug_igmp_events_cmd);
  3344. install_element (ENABLE_NODE, &no_debug_igmp_events_cmd);
  3345. install_element (ENABLE_NODE, &undebug_igmp_events_cmd);
  3346. install_element (ENABLE_NODE, &debug_igmp_packets_cmd);
  3347. install_element (ENABLE_NODE, &no_debug_igmp_packets_cmd);
  3348. install_element (ENABLE_NODE, &undebug_igmp_packets_cmd);
  3349. install_element (ENABLE_NODE, &debug_igmp_trace_cmd);
  3350. install_element (ENABLE_NODE, &no_debug_igmp_trace_cmd);
  3351. install_element (ENABLE_NODE, &undebug_igmp_trace_cmd);
  3352. install_element (ENABLE_NODE, &debug_pim_cmd);
  3353. install_element (ENABLE_NODE, &no_debug_pim_cmd);
  3354. install_element (ENABLE_NODE, &undebug_pim_cmd);
  3355. install_element (ENABLE_NODE, &debug_pim_events_cmd);
  3356. install_element (ENABLE_NODE, &no_debug_pim_events_cmd);
  3357. install_element (ENABLE_NODE, &undebug_pim_events_cmd);
  3358. install_element (ENABLE_NODE, &debug_pim_packets_cmd);
  3359. install_element (ENABLE_NODE, &no_debug_pim_packets_cmd);
  3360. install_element (ENABLE_NODE, &undebug_pim_packets_cmd);
  3361. install_element (ENABLE_NODE, &debug_pim_trace_cmd);
  3362. install_element (ENABLE_NODE, &no_debug_pim_trace_cmd);
  3363. install_element (ENABLE_NODE, &undebug_pim_trace_cmd);
  3364. install_element (ENABLE_NODE, &debug_ssmpingd_cmd);
  3365. install_element (ENABLE_NODE, &no_debug_ssmpingd_cmd);
  3366. install_element (ENABLE_NODE, &undebug_ssmpingd_cmd);
  3367. install_element (ENABLE_NODE, &debug_pim_zebra_cmd);
  3368. install_element (ENABLE_NODE, &no_debug_pim_zebra_cmd);
  3369. install_element (ENABLE_NODE, &undebug_pim_zebra_cmd);
  3370. install_element (CONFIG_NODE, &debug_igmp_cmd);
  3371. install_element (CONFIG_NODE, &no_debug_igmp_cmd);
  3372. install_element (CONFIG_NODE, &undebug_igmp_cmd);
  3373. install_element (CONFIG_NODE, &debug_igmp_events_cmd);
  3374. install_element (CONFIG_NODE, &no_debug_igmp_events_cmd);
  3375. install_element (CONFIG_NODE, &undebug_igmp_events_cmd);
  3376. install_element (CONFIG_NODE, &debug_igmp_packets_cmd);
  3377. install_element (CONFIG_NODE, &no_debug_igmp_packets_cmd);
  3378. install_element (CONFIG_NODE, &undebug_igmp_packets_cmd);
  3379. install_element (CONFIG_NODE, &debug_igmp_trace_cmd);
  3380. install_element (CONFIG_NODE, &no_debug_igmp_trace_cmd);
  3381. install_element (CONFIG_NODE, &undebug_igmp_trace_cmd);
  3382. install_element (CONFIG_NODE, &debug_pim_cmd);
  3383. install_element (CONFIG_NODE, &no_debug_pim_cmd);
  3384. install_element (CONFIG_NODE, &undebug_pim_cmd);
  3385. install_element (CONFIG_NODE, &debug_pim_events_cmd);
  3386. install_element (CONFIG_NODE, &no_debug_pim_events_cmd);
  3387. install_element (CONFIG_NODE, &undebug_pim_events_cmd);
  3388. install_element (CONFIG_NODE, &debug_pim_packets_cmd);
  3389. install_element (CONFIG_NODE, &no_debug_pim_packets_cmd);
  3390. install_element (CONFIG_NODE, &undebug_pim_packets_cmd);
  3391. install_element (CONFIG_NODE, &debug_pim_trace_cmd);
  3392. install_element (CONFIG_NODE, &no_debug_pim_trace_cmd);
  3393. install_element (CONFIG_NODE, &undebug_pim_trace_cmd);
  3394. install_element (CONFIG_NODE, &debug_ssmpingd_cmd);
  3395. install_element (CONFIG_NODE, &no_debug_ssmpingd_cmd);
  3396. install_element (CONFIG_NODE, &undebug_ssmpingd_cmd);
  3397. install_element (CONFIG_NODE, &debug_pim_zebra_cmd);
  3398. install_element (CONFIG_NODE, &no_debug_pim_zebra_cmd);
  3399. install_element (CONFIG_NODE, &undebug_pim_zebra_cmd);
  3400. }