12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923 |
- /*
- PIM for Quagga
- Copyright (C) 2008 Everton da Silva Marques
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
- This program is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; see the file COPYING; if not, write to the
- Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
- MA 02110-1301 USA
-
- $QuaggaId: $Format:%an, %ai, %h$ $
- */
- #include <sys/ioctl.h>
- #include <zebra.h>
- #include "command.h"
- #include "if.h"
- #include "prefix.h"
- #include "pimd.h"
- #include "pim_cmd.h"
- #include "pim_iface.h"
- #include "pim_vty.h"
- #include "pim_mroute.h"
- #include "pim_str.h"
- #include "pim_igmpv3.h"
- #include "pim_sock.h"
- #include "pim_time.h"
- #include "pim_util.h"
- #include "pim_oil.h"
- #include "pim_neighbor.h"
- #include "pim_pim.h"
- #include "pim_ifchannel.h"
- #include "pim_hello.h"
- #include "pim_msg.h"
- #include "pim_upstream.h"
- #include "pim_rpf.h"
- #include "pim_macro.h"
- static struct cmd_node pim_global_node = {
- PIM_NODE,
- "",
- 1 /* vtysh ? yes */
- };
- static struct cmd_node interface_node = {
- INTERFACE_NODE,
- "%s(config-if)# ",
- 1 /* vtysh ? yes */
- };
- static void pim_if_membership_clear(struct interface *ifp)
- {
- struct pim_interface *pim_ifp;
- pim_ifp = ifp->info;
- zassert(pim_ifp);
- if (PIM_IF_TEST_PIM(pim_ifp->options) &&
- PIM_IF_TEST_IGMP(pim_ifp->options)) {
- return;
- }
- pim_ifchannel_membership_clear(ifp);
- }
- /*
- When PIM is disabled on interface, IGMPv3 local membership
- information is not injected into PIM interface state.
- The function pim_if_membership_refresh() fetches all IGMPv3 local
- membership information into PIM. It is intented to be called
- whenever PIM is enabled on the interface in order to collect missed
- local membership information.
- */
- static void pim_if_membership_refresh(struct interface *ifp)
- {
- struct pim_interface *pim_ifp;
- struct listnode *sock_node;
- struct igmp_sock *igmp;
- pim_ifp = ifp->info;
- zassert(pim_ifp);
- if (!PIM_IF_TEST_PIM(pim_ifp->options))
- return;
- if (!PIM_IF_TEST_IGMP(pim_ifp->options))
- return;
- /*
- First clear off membership from all PIM (S,G) entries on the
- interface
- */
- pim_ifchannel_membership_clear(ifp);
- /*
- Then restore PIM (S,G) membership from all IGMPv3 (S,G) entries on
- the interface
- */
- /* scan igmp sockets */
- for (ALL_LIST_ELEMENTS_RO(pim_ifp->igmp_socket_list, sock_node, igmp)) {
- struct listnode *grpnode;
- struct igmp_group *grp;
-
- /* scan igmp groups */
- for (ALL_LIST_ELEMENTS_RO(igmp->igmp_group_list, grpnode, grp)) {
- struct listnode *srcnode;
- struct igmp_source *src;
-
- /* scan group sources */
- for (ALL_LIST_ELEMENTS_RO(grp->group_source_list, srcnode, src)) {
- if (IGMP_SOURCE_TEST_FORWARDING(src->source_flags)) {
- pim_ifchannel_local_membership_add(ifp,
- src->source_addr,
- grp->group_addr);
- }
-
- } /* scan group sources */
- } /* scan igmp groups */
- } /* scan igmp sockets */
- /*
- Finally delete every PIM (S,G) entry lacking all state info
- */
- pim_ifchannel_delete_on_noinfo(ifp);
- }
- static void pim_show_assert(struct vty *vty)
- {
- struct listnode *ifnode;
- struct interface *ifp;
- time_t now;
-
- now = pim_time_monotonic_sec();
- vty_out(vty,
- "Interface Address Source Group State Winner Uptime Timer%s",
- VTY_NEWLINE);
- for (ALL_LIST_ELEMENTS_RO(iflist, ifnode, ifp)) {
- struct pim_interface *pim_ifp;
- struct in_addr ifaddr;
- struct listnode *ch_node;
- struct pim_ifchannel *ch;
- pim_ifp = ifp->info;
-
- if (!pim_ifp)
- continue;
- ifaddr = pim_ifp->primary_address;
- for (ALL_LIST_ELEMENTS_RO(pim_ifp->pim_ifchannel_list, ch_node, ch)) {
- char ch_src_str[100];
- char ch_grp_str[100];
- char winner_str[100];
- char uptime[10];
- char timer[10];
- pim_inet4_dump("<ch_src?>", ch->source_addr,
- ch_src_str, sizeof(ch_src_str));
- pim_inet4_dump("<ch_grp?>", ch->group_addr,
- ch_grp_str, sizeof(ch_grp_str));
- pim_inet4_dump("<assrt_win?>", ch->ifassert_winner,
- winner_str, sizeof(winner_str));
- pim_time_uptime(uptime, sizeof(uptime), now - ch->ifassert_creation);
- pim_time_timer_to_mmss(timer, sizeof(timer),
- ch->t_ifassert_timer);
- vty_out(vty, "%-9s %-15s %-15s %-15s %-6s %-15s %-8s %-5s%s",
- ifp->name,
- inet_ntoa(ifaddr),
- ch_src_str,
- ch_grp_str,
- pim_ifchannel_ifassert_name(ch->ifassert_state),
- winner_str,
- uptime,
- timer,
- VTY_NEWLINE);
- } /* scan interface channels */
- } /* scan interfaces */
- }
- static void pim_show_assert_internal(struct vty *vty)
- {
- struct listnode *ifnode;
- struct interface *ifp;
- vty_out(vty,
- "CA: CouldAssert%s"
- "ECA: Evaluate CouldAssert%s"
- "ATD: AssertTrackingDesired%s"
- "eATD: Evaluate AssertTrackingDesired%s%s",
- VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE);
- vty_out(vty,
- "Interface Address Source Group CA eCA ATD eATD%s",
- VTY_NEWLINE);
- for (ALL_LIST_ELEMENTS_RO(iflist, ifnode, ifp)) {
- struct pim_interface *pim_ifp;
- struct in_addr ifaddr;
- struct listnode *ch_node;
- struct pim_ifchannel *ch;
- pim_ifp = ifp->info;
-
- if (!pim_ifp)
- continue;
- ifaddr = pim_ifp->primary_address;
- for (ALL_LIST_ELEMENTS_RO(pim_ifp->pim_ifchannel_list, ch_node, ch)) {
- char ch_src_str[100];
- char ch_grp_str[100];
- pim_inet4_dump("<ch_src?>", ch->source_addr,
- ch_src_str, sizeof(ch_src_str));
- pim_inet4_dump("<ch_grp?>", ch->group_addr,
- ch_grp_str, sizeof(ch_grp_str));
- vty_out(vty, "%-9s %-15s %-15s %-15s %-3s %-3s %-3s %-4s%s",
- ifp->name,
- inet_ntoa(ifaddr),
- ch_src_str,
- ch_grp_str,
- PIM_IF_FLAG_TEST_COULD_ASSERT(ch->flags) ? "yes" : "no",
- pim_macro_ch_could_assert_eval(ch) ? "yes" : "no",
- PIM_IF_FLAG_TEST_ASSERT_TRACKING_DESIRED(ch->flags) ? "yes" : "no",
- pim_macro_assert_tracking_desired_eval(ch) ? "yes" : "no",
- VTY_NEWLINE);
- } /* scan interface channels */
- } /* scan interfaces */
- }
- static void pim_show_assert_metric(struct vty *vty)
- {
- struct listnode *ifnode;
- struct interface *ifp;
-
- vty_out(vty,
- "Interface Address Source Group RPT Pref Metric Address %s",
- VTY_NEWLINE);
- for (ALL_LIST_ELEMENTS_RO(iflist, ifnode, ifp)) {
- struct pim_interface *pim_ifp;
- struct in_addr ifaddr;
- struct listnode *ch_node;
- struct pim_ifchannel *ch;
- pim_ifp = ifp->info;
-
- if (!pim_ifp)
- continue;
- ifaddr = pim_ifp->primary_address;
- for (ALL_LIST_ELEMENTS_RO(pim_ifp->pim_ifchannel_list, ch_node, ch)) {
- char ch_src_str[100];
- char ch_grp_str[100];
- char addr_str[100];
- struct pim_assert_metric am;
- am = pim_macro_spt_assert_metric(&ch->upstream->rpf, pim_ifp->primary_address);
- pim_inet4_dump("<ch_src?>", ch->source_addr,
- ch_src_str, sizeof(ch_src_str));
- pim_inet4_dump("<ch_grp?>", ch->group_addr,
- ch_grp_str, sizeof(ch_grp_str));
- pim_inet4_dump("<addr?>", am.ip_address,
- addr_str, sizeof(addr_str));
- vty_out(vty, "%-9s %-15s %-15s %-15s %-3s %4u %6u %-15s%s",
- ifp->name,
- inet_ntoa(ifaddr),
- ch_src_str,
- ch_grp_str,
- am.rpt_bit_flag ? "yes" : "no",
- am.metric_preference,
- am.route_metric,
- addr_str,
- VTY_NEWLINE);
- } /* scan interface channels */
- } /* scan interfaces */
- }
- static void pim_show_assert_winner_metric(struct vty *vty)
- {
- struct listnode *ifnode;
- struct interface *ifp;
-
- vty_out(vty,
- "Interface Address Source Group RPT Pref Metric Address %s",
- VTY_NEWLINE);
- for (ALL_LIST_ELEMENTS_RO(iflist, ifnode, ifp)) {
- struct pim_interface *pim_ifp;
- struct in_addr ifaddr;
- struct listnode *ch_node;
- struct pim_ifchannel *ch;
- pim_ifp = ifp->info;
-
- if (!pim_ifp)
- continue;
- ifaddr = pim_ifp->primary_address;
- for (ALL_LIST_ELEMENTS_RO(pim_ifp->pim_ifchannel_list, ch_node, ch)) {
- char ch_src_str[100];
- char ch_grp_str[100];
- char addr_str[100];
- struct pim_assert_metric *am;
- char pref_str[5];
- char metr_str[7];
- am = &ch->ifassert_winner_metric;
- pim_inet4_dump("<ch_src?>", ch->source_addr,
- ch_src_str, sizeof(ch_src_str));
- pim_inet4_dump("<ch_grp?>", ch->group_addr,
- ch_grp_str, sizeof(ch_grp_str));
- pim_inet4_dump("<addr?>", am->ip_address,
- addr_str, sizeof(addr_str));
- if (am->metric_preference == PIM_ASSERT_METRIC_PREFERENCE_MAX)
- snprintf(pref_str, sizeof(pref_str), "INFI");
- else
- snprintf(pref_str, sizeof(pref_str), "%4u", am->metric_preference);
- if (am->route_metric == PIM_ASSERT_ROUTE_METRIC_MAX)
- snprintf(metr_str, sizeof(metr_str), "INFI");
- else
- snprintf(metr_str, sizeof(metr_str), "%6u", am->route_metric);
- vty_out(vty, "%-9s %-15s %-15s %-15s %-3s %-4s %-6s %-15s%s",
- ifp->name,
- inet_ntoa(ifaddr),
- ch_src_str,
- ch_grp_str,
- am->rpt_bit_flag ? "yes" : "no",
- pref_str,
- metr_str,
- addr_str,
- VTY_NEWLINE);
- } /* scan interface channels */
- } /* scan interfaces */
- }
- static void pim_show_membership(struct vty *vty)
- {
- struct listnode *ifnode;
- struct interface *ifp;
- vty_out(vty,
- "Interface Address Source Group Membership%s",
- VTY_NEWLINE);
- for (ALL_LIST_ELEMENTS_RO(iflist, ifnode, ifp)) {
- struct pim_interface *pim_ifp;
- struct in_addr ifaddr;
- struct listnode *ch_node;
- struct pim_ifchannel *ch;
- pim_ifp = ifp->info;
-
- if (!pim_ifp)
- continue;
- ifaddr = pim_ifp->primary_address;
- for (ALL_LIST_ELEMENTS_RO(pim_ifp->pim_ifchannel_list, ch_node, ch)) {
- char ch_src_str[100];
- char ch_grp_str[100];
- pim_inet4_dump("<ch_src?>", ch->source_addr,
- ch_src_str, sizeof(ch_src_str));
- pim_inet4_dump("<ch_grp?>", ch->group_addr,
- ch_grp_str, sizeof(ch_grp_str));
- vty_out(vty, "%-9s %-15s %-15s %-15s %-10s%s",
- ifp->name,
- inet_ntoa(ifaddr),
- ch_src_str,
- ch_grp_str,
- ch->local_ifmembership == PIM_IFMEMBERSHIP_NOINFO ?
- "NOINFO" : "INCLUDE",
- VTY_NEWLINE);
- } /* scan interface channels */
- } /* scan interfaces */
- }
- static void igmp_show_interfaces(struct vty *vty)
- {
- struct listnode *node;
- struct interface *ifp;
- time_t now;
-
- now = pim_time_monotonic_sec();
- vty_out(vty,
- "Interface Address ifIndex Socket Uptime Multi Broad MLoop AllMu Prmsc Del%s",
- VTY_NEWLINE);
- for (ALL_LIST_ELEMENTS_RO(iflist, node, ifp)) {
- struct pim_interface *pim_ifp;
- struct listnode *sock_node;
- struct igmp_sock *igmp;
- pim_ifp = ifp->info;
-
- if (!pim_ifp)
- continue;
- for (ALL_LIST_ELEMENTS_RO(pim_ifp->igmp_socket_list, sock_node, igmp)) {
- char uptime[10];
- int mloop;
- pim_time_uptime(uptime, sizeof(uptime), now - igmp->sock_creation);
- mloop = pim_socket_mcastloop_get(igmp->fd);
-
- vty_out(vty, "%-9s %-15s %7d %6d %8s %5s %5s %5s %5s %5s %3s%s",
- ifp->name,
- inet_ntoa(igmp->ifaddr),
- ifp->ifindex,
- igmp->fd,
- uptime,
- if_is_multicast(ifp) ? "yes" : "no",
- if_is_broadcast(ifp) ? "yes" : "no",
- (mloop < 0) ? "?" : (mloop ? "yes" : "no"),
- (ifp->flags & IFF_ALLMULTI) ? "yes" : "no",
- (ifp->flags & IFF_PROMISC) ? "yes" : "no",
- PIM_IF_IS_DELETED(ifp) ? "yes" : "no",
- VTY_NEWLINE);
- }
- }
- }
- static void show_interface_address(struct vty *vty)
- {
- struct listnode *ifpnode;
- struct interface *ifp;
-
- vty_out(vty,
- "Interface Primary Secondary %s",
- VTY_NEWLINE);
- for (ALL_LIST_ELEMENTS_RO(iflist, ifpnode, ifp)) {
- struct listnode *ifcnode;
- struct connected *ifc;
- struct in_addr pri_addr;
- char pri_addr_str[100];
- pri_addr = pim_find_primary_addr(ifp);
- pim_inet4_dump("<pri?>", pri_addr, pri_addr_str, sizeof(pri_addr_str));
-
- for (ALL_LIST_ELEMENTS_RO(ifp->connected, ifcnode, ifc)) {
- char sec_addr_str[100];
- struct prefix *p = ifc->address;
- if (p->family != AF_INET)
- continue;
- if (p->u.prefix4.s_addr == pri_addr.s_addr) {
- sec_addr_str[0] = '\0';
- }
- else {
- pim_inet4_dump("<sec?>", p->u.prefix4, sec_addr_str, sizeof(sec_addr_str));
- }
-
- vty_out(vty, "%-9s %-15s %-15s%s",
- ifp->name,
- pri_addr_str,
- sec_addr_str,
- VTY_NEWLINE);
- }
- }
- }
- static void pim_show_dr(struct vty *vty)
- {
- struct listnode *node;
- struct interface *ifp;
- time_t now;
-
- now = pim_time_monotonic_sec();
- vty_out(vty,
- "NonPri: Number of neighbors missing DR Priority hello option%s%s",
- VTY_NEWLINE, VTY_NEWLINE);
-
- vty_out(vty, "Interface Address DR Uptime Elections NonPri%s", VTY_NEWLINE);
- for (ALL_LIST_ELEMENTS_RO(iflist, node, ifp)) {
- struct pim_interface *pim_ifp;
- struct in_addr ifaddr;
- char dr_str[100];
- char dr_uptime[10];
- pim_ifp = ifp->info;
-
- if (!pim_ifp)
- continue;
- if (pim_ifp->pim_sock_fd < 0)
- continue;
- ifaddr = pim_ifp->primary_address;
- pim_time_uptime(dr_uptime, sizeof(dr_uptime),
- now - pim_ifp->pim_dr_election_last);
- pim_inet4_dump("<dr?>", pim_ifp->pim_dr_addr,
- dr_str, sizeof(dr_str));
- vty_out(vty, "%-9s %-15s %-15s %8s %9d %6d%s",
- ifp->name,
- inet_ntoa(ifaddr),
- dr_str,
- dr_uptime,
- pim_ifp->pim_dr_election_count,
- pim_ifp->pim_dr_num_nondrpri_neighbors,
- VTY_NEWLINE);
- }
- }
- static void pim_show_hello(struct vty *vty)
- {
- struct listnode *node;
- struct interface *ifp;
- time_t now;
-
- now = pim_time_monotonic_sec();
-
- vty_out(vty, "Interface Address Period Timer StatStart Recv Rfail Send Sfail%s", VTY_NEWLINE);
- for (ALL_LIST_ELEMENTS_RO(iflist, node, ifp)) {
- struct pim_interface *pim_ifp;
- struct in_addr ifaddr;
- char hello_period[10];
- char hello_timer[10];
- char stat_uptime[10];
- pim_ifp = ifp->info;
-
- if (!pim_ifp)
- continue;
- if (pim_ifp->pim_sock_fd < 0)
- continue;
- ifaddr = pim_ifp->primary_address;
- pim_time_timer_to_mmss(hello_timer, sizeof(hello_timer), pim_ifp->t_pim_hello_timer);
- pim_time_mmss(hello_period, sizeof(hello_period), pim_ifp->pim_hello_period);
- pim_time_uptime(stat_uptime, sizeof(stat_uptime), now - pim_ifp->pim_ifstat_start);
- vty_out(vty, "%-9s %-15s %6s %5s %9s %4u %5u %4u %5u%s",
- ifp->name,
- inet_ntoa(ifaddr),
- hello_period,
- hello_timer,
- stat_uptime,
- pim_ifp->pim_ifstat_hello_recv,
- pim_ifp->pim_ifstat_hello_recvfail,
- pim_ifp->pim_ifstat_hello_sent,
- pim_ifp->pim_ifstat_hello_sendfail,
- VTY_NEWLINE);
- }
- }
- static void pim_show_interfaces(struct vty *vty)
- {
- struct listnode *node;
- struct interface *ifp;
- time_t now;
-
- now = pim_time_monotonic_sec();
- vty_out(vty, "Interface Address ifIndex Socket Uptime Multi Broad MLoop AllMu Prmsc Del%s", VTY_NEWLINE);
- for (ALL_LIST_ELEMENTS_RO(iflist, node, ifp)) {
- struct pim_interface *pim_ifp;
- struct in_addr ifaddr;
- char uptime[10];
- int mloop;
- pim_ifp = ifp->info;
-
- if (!pim_ifp)
- continue;
- if (pim_ifp->pim_sock_fd < 0)
- continue;
- ifaddr = pim_ifp->primary_address;
- pim_time_uptime(uptime, sizeof(uptime), now - pim_ifp->pim_sock_creation);
- mloop = pim_socket_mcastloop_get(pim_ifp->pim_sock_fd);
-
- vty_out(vty, "%-9s %-15s %7d %6d %8s %5s %5s %5s %5s %5s %3s%s",
- ifp->name,
- inet_ntoa(ifaddr),
- ifp->ifindex,
- pim_ifp->pim_sock_fd,
- uptime,
- if_is_multicast(ifp) ? "yes" : "no",
- if_is_broadcast(ifp) ? "yes" : "no",
- (mloop < 0) ? "?" : (mloop ? "yes" : "no"),
- (ifp->flags & IFF_ALLMULTI) ? "yes" : "no",
- (ifp->flags & IFF_PROMISC) ? "yes" : "no",
- PIM_IF_IS_DELETED(ifp) ? "yes" : "no",
- VTY_NEWLINE);
- }
- }
- static void pim_show_join(struct vty *vty)
- {
- struct listnode *ifnode;
- struct interface *ifp;
- time_t now;
-
- now = pim_time_monotonic_sec();
- vty_out(vty,
- "Interface Address Source Group State Uptime Expire Prune%s",
- VTY_NEWLINE);
- for (ALL_LIST_ELEMENTS_RO(iflist, ifnode, ifp)) {
- struct pim_interface *pim_ifp;
- struct in_addr ifaddr;
- struct listnode *ch_node;
- struct pim_ifchannel *ch;
- pim_ifp = ifp->info;
-
- if (!pim_ifp)
- continue;
- ifaddr = pim_ifp->primary_address;
- for (ALL_LIST_ELEMENTS_RO(pim_ifp->pim_ifchannel_list, ch_node, ch)) {
- char ch_src_str[100];
- char ch_grp_str[100];
- char uptime[10];
- char expire[10];
- char prune[10];
- pim_inet4_dump("<ch_src?>", ch->source_addr,
- ch_src_str, sizeof(ch_src_str));
- pim_inet4_dump("<ch_grp?>", ch->group_addr,
- ch_grp_str, sizeof(ch_grp_str));
- pim_time_uptime(uptime, sizeof(uptime), now - ch->ifjoin_creation);
- pim_time_timer_to_mmss(expire, sizeof(expire),
- ch->t_ifjoin_expiry_timer);
- pim_time_timer_to_mmss(prune, sizeof(prune),
- ch->t_ifjoin_prune_pending_timer);
- vty_out(vty, "%-9s %-15s %-15s %-15s %-6s %8s %-6s %5s%s",
- ifp->name,
- inet_ntoa(ifaddr),
- ch_src_str,
- ch_grp_str,
- pim_ifchannel_ifjoin_name(ch->ifjoin_state),
- uptime,
- expire,
- prune,
- VTY_NEWLINE);
- } /* scan interface channels */
- } /* scan interfaces */
- }
- static void pim_show_neighbors(struct vty *vty)
- {
- struct listnode *node;
- struct interface *ifp;
- time_t now;
-
- now = pim_time_monotonic_sec();
- vty_out(vty,
- "Recv flags: H=holdtime L=lan_prune_delay P=dr_priority G=generation_id A=address_list%s"
- " T=can_disable_join_suppression%s%s",
- VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE);
- vty_out(vty, "Interface Address Neighbor Uptime Timer Holdt DrPri GenId Recv %s", VTY_NEWLINE);
- for (ALL_LIST_ELEMENTS_RO(iflist, node, ifp)) {
- struct pim_interface *pim_ifp;
- struct in_addr ifaddr;
- struct listnode *neighnode;
- struct pim_neighbor *neigh;
- pim_ifp = ifp->info;
-
- if (!pim_ifp)
- continue;
- if (pim_ifp->pim_sock_fd < 0)
- continue;
- ifaddr = pim_ifp->primary_address;
- for (ALL_LIST_ELEMENTS_RO(pim_ifp->pim_neighbor_list, neighnode, neigh)) {
- char uptime[10];
- char holdtime[10];
- char expire[10];
- char neigh_src_str[100];
- char recv[7];
- pim_inet4_dump("<src?>", neigh->source_addr,
- neigh_src_str, sizeof(neigh_src_str));
- pim_time_uptime(uptime, sizeof(uptime), now - neigh->creation);
- pim_time_mmss(holdtime, sizeof(holdtime), neigh->holdtime);
- pim_time_timer_to_mmss(expire, sizeof(expire), neigh->t_expire_timer);
- recv[0] = PIM_OPTION_IS_SET(neigh->hello_options, PIM_OPTION_MASK_HOLDTIME) ? 'H' : ' ';
- recv[1] = PIM_OPTION_IS_SET(neigh->hello_options, PIM_OPTION_MASK_LAN_PRUNE_DELAY) ? 'L' : ' ';
- recv[2] = PIM_OPTION_IS_SET(neigh->hello_options, PIM_OPTION_MASK_DR_PRIORITY) ? 'P' : ' ';
- recv[3] = PIM_OPTION_IS_SET(neigh->hello_options, PIM_OPTION_MASK_GENERATION_ID) ? 'G' : ' ';
- recv[4] = PIM_OPTION_IS_SET(neigh->hello_options, PIM_OPTION_MASK_ADDRESS_LIST) ? 'A' : ' ';
- recv[5] = PIM_OPTION_IS_SET(neigh->hello_options, PIM_OPTION_MASK_CAN_DISABLE_JOIN_SUPPRESSION) ? 'T' : ' ';
- recv[6] = '\0';
- vty_out(vty, "%-9s %-15s %-15s %8s %5s %5s %5u %08x %6s%s",
- ifp->name,
- inet_ntoa(ifaddr),
- neigh_src_str,
- uptime,
- expire,
- holdtime,
- neigh->dr_priority,
- neigh->generation_id,
- recv,
- VTY_NEWLINE);
- }
- }
- }
- static void pim_show_lan_prune_delay(struct vty *vty)
- {
- struct listnode *node;
- struct interface *ifp;
- vty_out(vty,
- "PrDly=propagation_delay (msec) OvInt=override_interval (msec)%s"
- "HiDly=highest_propagation_delay (msec) HiInt=highest_override_interval (msec)%s"
- "NoDly=number_of_non_lan_delay_neighbors%s"
- "T=t_bit LPD=lan_prune_delay_hello_option%s%s",
- VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE);
- vty_out(vty, "Interface Address PrDly OvInt NoDly HiDly HiInt T Neighbor LPD PrDly OvInt T%s", VTY_NEWLINE);
- for (ALL_LIST_ELEMENTS_RO(iflist, node, ifp)) {
- struct pim_interface *pim_ifp;
- struct in_addr ifaddr;
- struct listnode *neighnode;
- struct pim_neighbor *neigh;
- pim_ifp = ifp->info;
-
- if (!pim_ifp)
- continue;
- if (pim_ifp->pim_sock_fd < 0)
- continue;
- ifaddr = pim_ifp->primary_address;
- for (ALL_LIST_ELEMENTS_RO(pim_ifp->pim_neighbor_list, neighnode, neigh)) {
- char neigh_src_str[100];
- pim_inet4_dump("<src?>", neigh->source_addr,
- neigh_src_str, sizeof(neigh_src_str));
- vty_out(vty, "%-9s %-15s %5u %5u %5u %5u %5u %1u %-15s %s %5u %5u %1u%s",
- ifp->name,
- inet_ntoa(ifaddr),
- pim_ifp->pim_propagation_delay_msec,
- pim_ifp->pim_override_interval_msec,
- pim_ifp->pim_number_of_nonlandelay_neighbors,
- pim_ifp->pim_neighbors_highest_propagation_delay_msec,
- pim_ifp->pim_neighbors_highest_override_interval_msec,
- PIM_FORCE_BOOLEAN(PIM_IF_TEST_PIM_CAN_DISABLE_JOIN_SUPRESSION(pim_ifp->options)),
- neigh_src_str,
- PIM_OPTION_IS_SET(neigh->hello_options, PIM_OPTION_MASK_LAN_PRUNE_DELAY) ? "yes" : "no",
- neigh->propagation_delay_msec,
- neigh->override_interval_msec,
- PIM_FORCE_BOOLEAN(PIM_OPTION_IS_SET(neigh->hello_options,
- PIM_OPTION_MASK_CAN_DISABLE_JOIN_SUPPRESSION)),
- VTY_NEWLINE);
- }
- }
- }
- static void pim_show_jp_override_interval(struct vty *vty)
- {
- struct listnode *node;
- struct interface *ifp;
- vty_out(vty,
- "EffPDelay=effective_propagation_delay (msec)%s"
- "EffOvrInt=override_interval (msec)%s"
- "JPOvrInt=jp_override_interval (msec)%s%s",
- VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE);
- vty_out(vty, "Interface Address LAN_Delay EffPDelay EffOvrInt JPOvrInt%s", VTY_NEWLINE);
- for (ALL_LIST_ELEMENTS_RO(iflist, node, ifp)) {
- struct pim_interface *pim_ifp;
- struct in_addr ifaddr;
- pim_ifp = ifp->info;
-
- if (!pim_ifp)
- continue;
- if (pim_ifp->pim_sock_fd < 0)
- continue;
- ifaddr = pim_ifp->primary_address;
- vty_out(vty, "%-9s %-15s %-9s %9u %9u %8u%s",
- ifp->name,
- inet_ntoa(ifaddr),
- pim_if_lan_delay_enabled(ifp) ? "enabled" : "disabled",
- pim_if_effective_propagation_delay_msec(ifp),
- pim_if_effective_override_interval_msec(ifp),
- pim_if_jp_override_interval_msec(ifp),
- VTY_NEWLINE);
- }
- }
- static void pim_show_neighbors_secondary(struct vty *vty)
- {
- struct listnode *node;
- struct interface *ifp;
- vty_out(vty, "Interface Address Neighbor Secondary %s", VTY_NEWLINE);
- for (ALL_LIST_ELEMENTS_RO(iflist, node, ifp)) {
- struct pim_interface *pim_ifp;
- struct in_addr ifaddr;
- struct listnode *neighnode;
- struct pim_neighbor *neigh;
- pim_ifp = ifp->info;
-
- if (!pim_ifp)
- continue;
- if (pim_ifp->pim_sock_fd < 0)
- continue;
- ifaddr = pim_ifp->primary_address;
- for (ALL_LIST_ELEMENTS_RO(pim_ifp->pim_neighbor_list, neighnode, neigh)) {
- char neigh_src_str[100];
- struct listnode *prefix_node;
- struct prefix *p;
- if (!neigh->prefix_list)
- continue;
- pim_inet4_dump("<src?>", neigh->source_addr,
- neigh_src_str, sizeof(neigh_src_str));
- for (ALL_LIST_ELEMENTS_RO(neigh->prefix_list, prefix_node, p)) {
- char neigh_sec_str[100];
- if (p->family != AF_INET)
- continue;
- pim_inet4_dump("<src?>", p->u.prefix4,
- neigh_sec_str, sizeof(neigh_sec_str));
- vty_out(vty, "%-9s %-15s %-15s %-15s%s",
- ifp->name,
- inet_ntoa(ifaddr),
- neigh_src_str,
- neigh_sec_str,
- VTY_NEWLINE);
- }
- }
- }
- }
- static void pim_show_upstream(struct vty *vty)
- {
- struct listnode *upnode;
- struct pim_upstream *up;
- time_t now;
- now = pim_time_monotonic_sec();
- vty_out(vty, "Source Group State Uptime JoinTimer RefCnt%s", VTY_NEWLINE);
- for (ALL_LIST_ELEMENTS_RO(qpim_upstream_list, upnode, up)) {
- char src_str[100];
- char grp_str[100];
- char uptime[10];
- char join_timer[10];
- pim_inet4_dump("<src?>", up->source_addr, src_str, sizeof(src_str));
- pim_inet4_dump("<grp?>", up->group_addr, grp_str, sizeof(grp_str));
- pim_time_uptime(uptime, sizeof(uptime), now - up->state_transition);
- pim_time_timer_to_hhmmss(join_timer, sizeof(join_timer), up->t_join_timer);
- vty_out(vty, "%-15s %-15s %-5s %-8s %-9s %6d%s",
- src_str,
- grp_str,
- up->join_state == PIM_UPSTREAM_JOINED ? "Jnd" : "NtJnd",
- uptime,
- join_timer,
- up->ref_count,
- VTY_NEWLINE);
- }
- }
- static void pim_show_join_desired(struct vty *vty)
- {
- struct listnode *ifnode;
- struct listnode *chnode;
- struct interface *ifp;
- struct pim_interface *pim_ifp;
- struct pim_ifchannel *ch;
- struct in_addr me_ifaddr;
- char src_str[100];
- char grp_str[100];
- vty_out(vty,
- "Interface Source Group LostAssert Joins PimInclude JoinDesired EvalJD%s",
- VTY_NEWLINE);
- /* scan all interfaces */
- for (ALL_LIST_ELEMENTS_RO(iflist, ifnode, ifp)) {
- pim_ifp = ifp->info;
- if (!pim_ifp)
- continue;
- me_ifaddr = pim_ifp->primary_address;
- /* scan per-interface (S,G) state */
- for (ALL_LIST_ELEMENTS_RO(pim_ifp->pim_ifchannel_list, chnode, ch)) {
- struct pim_upstream *up = ch->upstream;
- pim_inet4_dump("<src?>", up->source_addr, src_str, sizeof(src_str));
- pim_inet4_dump("<grp?>", up->group_addr, grp_str, sizeof(grp_str));
- vty_out(vty, "%-9s %-15s %-15s %-10s %-5s %-10s %-11s %-6s%s",
- ifp->name,
- src_str,
- grp_str,
- pim_macro_ch_lost_assert(ch) ? "yes" : "no",
- pim_macro_chisin_joins(ch) ? "yes" : "no",
- pim_macro_chisin_pim_include(ch) ? "yes" : "no",
- PIM_UPSTREAM_FLAG_TEST_DR_JOIN_DESIRED(up->flags) ? "yes" : "no",
- pim_upstream_evaluate_join_desired(up) ? "yes" : "no",
- VTY_NEWLINE);
- }
- }
- }
- static void pim_show_upstream_rpf(struct vty *vty)
- {
- struct listnode *upnode;
- struct pim_upstream *up;
- vty_out(vty,
- "Source Group RpfIface RibNextHop RpfAddress %s",
- VTY_NEWLINE);
- for (ALL_LIST_ELEMENTS_RO(qpim_upstream_list, upnode, up)) {
- char src_str[100];
- char grp_str[100];
- char rpf_nexthop_str[100];
- char rpf_addr_str[100];
- struct pim_rpf *rpf;
- const char *rpf_ifname;
-
- rpf = &up->rpf;
-
- pim_inet4_dump("<src?>", up->source_addr, src_str, sizeof(src_str));
- pim_inet4_dump("<grp?>", up->group_addr, grp_str, sizeof(grp_str));
- pim_inet4_dump("<nexthop?>", rpf->source_nexthop.mrib_nexthop_addr, rpf_nexthop_str, sizeof(rpf_nexthop_str));
- pim_inet4_dump("<rpf?>", rpf->rpf_addr, rpf_addr_str, sizeof(rpf_addr_str));
-
- rpf_ifname = rpf->source_nexthop.interface ? rpf->source_nexthop.interface->name : "<ifname?>";
-
- vty_out(vty, "%-15s %-15s %-8s %-15s %-15s%s",
- src_str,
- grp_str,
- rpf_ifname,
- rpf_nexthop_str,
- rpf_addr_str,
- VTY_NEWLINE);
- }
- }
- static void pim_show_rpf(struct vty *vty)
- {
- struct listnode *up_node;
- struct pim_upstream *up;
- vty_out(vty,
- "Source Group RpfIface RpfAddress RibNextHop Metric Pref%s",
- VTY_NEWLINE);
- for (ALL_LIST_ELEMENTS_RO(qpim_upstream_list, up_node, up)) {
- char src_str[100];
- char grp_str[100];
- char rpf_addr_str[100];
- char rib_nexthop_str[100];
- const char *rpf_ifname;
- struct pim_rpf *rpf = &up->rpf;
-
- pim_inet4_dump("<src?>", up->source_addr, src_str, sizeof(src_str));
- pim_inet4_dump("<grp?>", up->group_addr, grp_str, sizeof(grp_str));
- pim_inet4_dump("<rpf?>", rpf->rpf_addr, rpf_addr_str, sizeof(rpf_addr_str));
- pim_inet4_dump("<nexthop?>", rpf->source_nexthop.mrib_nexthop_addr, rib_nexthop_str, sizeof(rib_nexthop_str));
-
- rpf_ifname = rpf->source_nexthop.interface ? rpf->source_nexthop.interface->name : "<ifname?>";
-
- vty_out(vty, "%-15s %-15s %-8s %-15s %-15s %6d %4d%s",
- src_str,
- grp_str,
- rpf_ifname,
- rpf_addr_str,
- rib_nexthop_str,
- rpf->source_nexthop.mrib_route_metric,
- rpf->source_nexthop.mrib_metric_preference,
- VTY_NEWLINE);
- }
- }
- static void igmp_show_querier(struct vty *vty)
- {
- struct listnode *node;
- struct interface *ifp;
- time_t now;
-
- now = pim_time_monotonic_sec();
- vty_out(vty, "Interface Address Querier StartCount Query-Timer Other-Timer%s", VTY_NEWLINE);
- for (ALL_LIST_ELEMENTS_RO(iflist, node, ifp)) {
- struct pim_interface *pim_ifp = ifp->info;
- struct listnode *sock_node;
- struct igmp_sock *igmp;
-
- if (!pim_ifp)
- continue;
- for (ALL_LIST_ELEMENTS_RO(pim_ifp->igmp_socket_list, sock_node, igmp)) {
- char query_hhmmss[10];
- char other_hhmmss[10];
- pim_time_timer_to_hhmmss(query_hhmmss, sizeof(query_hhmmss), igmp->t_igmp_query_timer);
- pim_time_timer_to_hhmmss(other_hhmmss, sizeof(other_hhmmss), igmp->t_other_querier_timer);
- vty_out(vty, "%-9s %-15s %7s %10d %11s %11s%s",
- ifp->name,
- inet_ntoa(igmp->ifaddr),
- igmp->t_igmp_query_timer ? "THIS" : "OTHER",
- igmp->startup_query_count,
- query_hhmmss,
- other_hhmmss,
- VTY_NEWLINE);
- }
- }
- }
- static void igmp_show_groups(struct vty *vty)
- {
- struct listnode *ifnode;
- struct interface *ifp;
- time_t now;
- now = pim_time_monotonic_sec();
- vty_out(vty, "Interface Address Group Mode Timer Srcs V Uptime %s", VTY_NEWLINE);
- /* scan interfaces */
- for (ALL_LIST_ELEMENTS_RO(iflist, ifnode, ifp)) {
- struct pim_interface *pim_ifp = ifp->info;
- struct listnode *sock_node;
- struct igmp_sock *igmp;
-
- if (!pim_ifp)
- continue;
-
- /* scan igmp sockets */
- for (ALL_LIST_ELEMENTS_RO(pim_ifp->igmp_socket_list, sock_node, igmp)) {
- char ifaddr_str[100];
- struct listnode *grpnode;
- struct igmp_group *grp;
- pim_inet4_dump("<ifaddr?>", igmp->ifaddr, ifaddr_str, sizeof(ifaddr_str));
- /* scan igmp groups */
- for (ALL_LIST_ELEMENTS_RO(igmp->igmp_group_list, grpnode, grp)) {
- char group_str[100];
- char hhmmss[10];
- char uptime[10];
- pim_inet4_dump("<group?>", grp->group_addr, group_str, sizeof(group_str));
- pim_time_timer_to_hhmmss(hhmmss, sizeof(hhmmss), grp->t_group_timer);
- pim_time_uptime(uptime, sizeof(uptime), now - grp->group_creation);
- vty_out(vty, "%-9s %-15s %-15s %4s %8s %4d %d %8s%s",
- ifp->name,
- ifaddr_str,
- group_str,
- grp->group_filtermode_isexcl ? "EXCL" : "INCL",
- hhmmss,
- grp->group_source_list ? listcount(grp->group_source_list) : 0,
- igmp_group_compat_mode(igmp, grp),
- uptime,
- VTY_NEWLINE);
- } /* scan igmp groups */
- } /* scan igmp sockets */
- } /* scan interfaces */
- }
- static void igmp_show_group_retransmission(struct vty *vty)
- {
- struct listnode *ifnode;
- struct interface *ifp;
- time_t now;
- now = pim_time_monotonic_sec();
- vty_out(vty, "Interface Address Group RetTimer Counter RetSrcs%s", VTY_NEWLINE);
- /* scan interfaces */
- for (ALL_LIST_ELEMENTS_RO(iflist, ifnode, ifp)) {
- struct pim_interface *pim_ifp = ifp->info;
- struct listnode *sock_node;
- struct igmp_sock *igmp;
-
- if (!pim_ifp)
- continue;
-
- /* scan igmp sockets */
- for (ALL_LIST_ELEMENTS_RO(pim_ifp->igmp_socket_list, sock_node, igmp)) {
- char ifaddr_str[100];
- struct listnode *grpnode;
- struct igmp_group *grp;
- pim_inet4_dump("<ifaddr?>", igmp->ifaddr, ifaddr_str, sizeof(ifaddr_str));
- /* scan igmp groups */
- for (ALL_LIST_ELEMENTS_RO(igmp->igmp_group_list, grpnode, grp)) {
- char group_str[100];
- char grp_retr_mmss[10];
- struct listnode *src_node;
- struct igmp_source *src;
- int grp_retr_sources = 0;
- pim_inet4_dump("<group?>", grp->group_addr, group_str, sizeof(group_str));
- pim_time_timer_to_mmss(grp_retr_mmss, sizeof(grp_retr_mmss), grp->t_group_query_retransmit_timer);
- /* count group sources with retransmission state */
- for (ALL_LIST_ELEMENTS_RO(grp->group_source_list, src_node, src)) {
- if (src->source_query_retransmit_count > 0) {
- ++grp_retr_sources;
- }
- }
- vty_out(vty, "%-9s %-15s %-15s %-8s %7d %7d%s",
- ifp->name,
- ifaddr_str,
- group_str,
- grp_retr_mmss,
- grp->group_specific_query_retransmit_count,
- grp_retr_sources,
- VTY_NEWLINE);
- } /* scan igmp groups */
- } /* scan igmp sockets */
- } /* scan interfaces */
- }
- static void igmp_show_parameters(struct vty *vty)
- {
- struct listnode *ifnode;
- struct interface *ifp;
- vty_out(vty,
- "QRV: Robustness Variable SQI: Startup Query Interval%s"
- "QQI: Query Interval OQPI: Other Querier Present Interval%s"
- "QRI: Query Response Interval LMQT: Last Member Query Time%s"
- "GMI: Group Membership Interval OHPI: Older Host Present Interval%s%s",
- VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE);
- vty_out(vty,
- "Interface Address QRV QQI QRI GMI SQI OQPI LMQT OHPI %s",
- VTY_NEWLINE);
- /* scan interfaces */
- for (ALL_LIST_ELEMENTS_RO(iflist, ifnode, ifp)) {
- struct pim_interface *pim_ifp = ifp->info;
- struct listnode *sock_node;
- struct igmp_sock *igmp;
-
- if (!pim_ifp)
- continue;
-
- /* scan igmp sockets */
- for (ALL_LIST_ELEMENTS_RO(pim_ifp->igmp_socket_list, sock_node, igmp)) {
- char ifaddr_str[100];
- long gmi_dsec; /* Group Membership Interval */
- long oqpi_dsec; /* Other Querier Present Interval */
- int sqi;
- long lmqt_dsec;
- long ohpi_dsec;
- long qri_dsec;
- pim_inet4_dump("<ifaddr?>", igmp->ifaddr, ifaddr_str, sizeof(ifaddr_str));
- gmi_dsec = PIM_IGMP_GMI_MSEC(igmp->querier_robustness_variable,
- igmp->querier_query_interval,
- pim_ifp->igmp_query_max_response_time_dsec) / 100;
- sqi = PIM_IGMP_SQI(pim_ifp->igmp_default_query_interval);
- oqpi_dsec = PIM_IGMP_OQPI_MSEC(igmp->querier_robustness_variable,
- igmp->querier_query_interval,
- pim_ifp->igmp_query_max_response_time_dsec) / 100;
- lmqt_dsec = PIM_IGMP_LMQT_MSEC(pim_ifp->igmp_query_max_response_time_dsec,
- igmp->querier_robustness_variable) / 100;
- ohpi_dsec = PIM_IGMP_OHPI_DSEC(igmp->querier_robustness_variable,
- igmp->querier_query_interval,
- pim_ifp->igmp_query_max_response_time_dsec);
- qri_dsec = pim_ifp->igmp_query_max_response_time_dsec;
- vty_out(vty,
- "%-9s %-15s %3d %3d %3ld.%ld %3ld.%ld %3d %3ld.%ld %3ld.%ld %3ld.%ld%s",
- ifp->name,
- ifaddr_str,
- igmp->querier_robustness_variable,
- igmp->querier_query_interval,
- qri_dsec / 10, qri_dsec % 10,
- gmi_dsec / 10, gmi_dsec % 10,
- sqi,
- oqpi_dsec / 10, oqpi_dsec % 10,
- lmqt_dsec / 10, lmqt_dsec % 10,
- ohpi_dsec / 10, ohpi_dsec % 10,
- VTY_NEWLINE);
- } /* scan igmp sockets */
- } /* scan interfaces */
- }
- static void igmp_show_sources(struct vty *vty)
- {
- struct listnode *ifnode;
- struct interface *ifp;
- time_t now;
- now = pim_time_monotonic_sec();
- vty_out(vty, "Interface Address Group Source Timer Fwd Uptime %s", VTY_NEWLINE);
- /* scan interfaces */
- for (ALL_LIST_ELEMENTS_RO(iflist, ifnode, ifp)) {
- struct pim_interface *pim_ifp = ifp->info;
- struct listnode *sock_node;
- struct igmp_sock *igmp;
-
- if (!pim_ifp)
- continue;
-
- /* scan igmp sockets */
- for (ALL_LIST_ELEMENTS_RO(pim_ifp->igmp_socket_list, sock_node, igmp)) {
- char ifaddr_str[100];
- struct listnode *grpnode;
- struct igmp_group *grp;
- pim_inet4_dump("<ifaddr?>", igmp->ifaddr, ifaddr_str, sizeof(ifaddr_str));
- /* scan igmp groups */
- for (ALL_LIST_ELEMENTS_RO(igmp->igmp_group_list, grpnode, grp)) {
- char group_str[100];
- struct listnode *srcnode;
- struct igmp_source *src;
- pim_inet4_dump("<group?>", grp->group_addr, group_str, sizeof(group_str));
-
- /* scan group sources */
- for (ALL_LIST_ELEMENTS_RO(grp->group_source_list, srcnode, src)) {
- char source_str[100];
- char mmss[10];
- char uptime[10];
- pim_inet4_dump("<source?>", src->source_addr, source_str, sizeof(source_str));
- pim_time_timer_to_mmss(mmss, sizeof(mmss), src->t_source_timer);
- pim_time_uptime(uptime, sizeof(uptime), now - src->source_creation);
- vty_out(vty, "%-9s %-15s %-15s %-15s %5s %3s %8s%s",
- ifp->name,
- ifaddr_str,
- group_str,
- source_str,
- mmss,
- IGMP_SOURCE_TEST_FORWARDING(src->source_flags) ? "Y" : "N",
- uptime,
- VTY_NEWLINE);
-
- } /* scan group sources */
- } /* scan igmp groups */
- } /* scan igmp sockets */
- } /* scan interfaces */
- }
- static void igmp_show_source_retransmission(struct vty *vty)
- {
- struct listnode *ifnode;
- struct interface *ifp;
- time_t now;
- now = pim_time_monotonic_sec();
- vty_out(vty, "Interface Address Group Source Counter%s", VTY_NEWLINE);
- /* scan interfaces */
- for (ALL_LIST_ELEMENTS_RO(iflist, ifnode, ifp)) {
- struct pim_interface *pim_ifp = ifp->info;
- struct listnode *sock_node;
- struct igmp_sock *igmp;
-
- if (!pim_ifp)
- continue;
-
- /* scan igmp sockets */
- for (ALL_LIST_ELEMENTS_RO(pim_ifp->igmp_socket_list, sock_node, igmp)) {
- char ifaddr_str[100];
- struct listnode *grpnode;
- struct igmp_group *grp;
- pim_inet4_dump("<ifaddr?>", igmp->ifaddr, ifaddr_str, sizeof(ifaddr_str));
- /* scan igmp groups */
- for (ALL_LIST_ELEMENTS_RO(igmp->igmp_group_list, grpnode, grp)) {
- char group_str[100];
- struct listnode *srcnode;
- struct igmp_source *src;
- pim_inet4_dump("<group?>", grp->group_addr, group_str, sizeof(group_str));
-
- /* scan group sources */
- for (ALL_LIST_ELEMENTS_RO(grp->group_source_list, srcnode, src)) {
- char source_str[100];
- pim_inet4_dump("<source?>", src->source_addr, source_str, sizeof(source_str));
- vty_out(vty, "%-9s %-15s %-15s %-15s %7d%s",
- ifp->name,
- ifaddr_str,
- group_str,
- source_str,
- src->source_query_retransmit_count,
- VTY_NEWLINE);
-
- } /* scan group sources */
- } /* scan igmp groups */
- } /* scan igmp sockets */
- } /* scan interfaces */
- }
- static void clear_igmp_interfaces()
- {
- struct listnode *ifnode;
- struct listnode *ifnextnode;
- struct interface *ifp;
- for (ALL_LIST_ELEMENTS(iflist, ifnode, ifnextnode, ifp)) {
- pim_if_addr_del_all_igmp(ifp);
- }
- for (ALL_LIST_ELEMENTS(iflist, ifnode, ifnextnode, ifp)) {
- pim_if_addr_add_all(ifp);
- }
- }
- static void clear_pim_interfaces()
- {
- struct listnode *ifnode;
- struct listnode *ifnextnode;
- struct interface *ifp;
- for (ALL_LIST_ELEMENTS(iflist, ifnode, ifnextnode, ifp)) {
- if (ifp->info) {
- pim_neighbor_delete_all(ifp, "interface cleared");
- }
- }
- }
- static void clear_interfaces()
- {
- clear_igmp_interfaces();
- clear_pim_interfaces();
- }
- DEFUN (pim_interface,
- pim_interface_cmd,
- "interface IFNAME",
- "Select an interface to configure\n"
- "Interface's name\n")
- {
- struct interface *ifp;
- const char *ifname = argv[0];
- size_t sl;
- sl = strlen(ifname);
- if (sl > INTERFACE_NAMSIZ) {
- vty_out(vty, "%% Interface name %s is invalid: length exceeds "
- "%d characters%s",
- ifname, INTERFACE_NAMSIZ, VTY_NEWLINE);
- return CMD_WARNING;
- }
- ifp = if_lookup_by_name_len(ifname, sl);
- if (!ifp) {
- vty_out(vty, "%% Interface %s does not exist%s", ifname, VTY_NEWLINE);
- /* Returning here would prevent pimd from booting when there are
- interface commands in pimd.conf, since all interfaces are
- unknown at pimd boot time (the zebra daemon has not been
- contacted for interface discovery). */
-
- ifp = if_get_by_name_len(ifname, sl);
- if (!ifp) {
- vty_out(vty, "%% Could not create interface %s%s", ifname, VTY_NEWLINE);
- return CMD_WARNING;
- }
- }
- vty->index = ifp;
- vty->node = INTERFACE_NODE;
- return CMD_SUCCESS;
- }
- DEFUN (clear_ip_interfaces,
- clear_ip_interfaces_cmd,
- "clear ip interfaces",
- CLEAR_STR
- IP_STR
- "Reset interfaces\n")
- {
- clear_interfaces();
- return CMD_SUCCESS;
- }
- DEFUN (clear_ip_igmp_interfaces,
- clear_ip_igmp_interfaces_cmd,
- "clear ip igmp interfaces",
- CLEAR_STR
- IP_STR
- CLEAR_IP_IGMP_STR
- "Reset IGMP interfaces\n")
- {
- clear_igmp_interfaces();
- return CMD_SUCCESS;
- }
- DEFUN (clear_ip_pim_interfaces,
- clear_ip_pim_interfaces_cmd,
- "clear ip pim interfaces",
- CLEAR_STR
- IP_STR
- CLEAR_IP_PIM_STR
- "Reset PIM interfaces\n")
- {
- clear_pim_interfaces();
- return CMD_SUCCESS;
- }
- DEFUN (show_ip_igmp_interface,
- show_ip_igmp_interface_cmd,
- "show ip igmp interface",
- SHOW_STR
- IP_STR
- IGMP_STR
- "IGMP interface information\n")
- {
- igmp_show_interfaces(vty);
- return CMD_SUCCESS;
- }
- DEFUN (show_ip_igmp_groups,
- show_ip_igmp_groups_cmd,
- "show ip igmp groups",
- SHOW_STR
- IP_STR
- IGMP_STR
- IGMP_GROUP_STR)
- {
- igmp_show_groups(vty);
- return CMD_SUCCESS;
- }
- DEFUN (show_ip_igmp_groups_retransmissions,
- show_ip_igmp_groups_retransmissions_cmd,
- "show ip igmp groups retransmissions",
- SHOW_STR
- IP_STR
- IGMP_STR
- IGMP_GROUP_STR
- "IGMP group retransmissions\n")
- {
- igmp_show_group_retransmission(vty);
- return CMD_SUCCESS;
- }
- DEFUN (show_ip_igmp_parameters,
- show_ip_igmp_parameters_cmd,
- "show ip igmp parameters",
- SHOW_STR
- IP_STR
- IGMP_STR
- "IGMP parameters information\n")
- {
- igmp_show_parameters(vty);
- return CMD_SUCCESS;
- }
- DEFUN (show_ip_igmp_sources,
- show_ip_igmp_sources_cmd,
- "show ip igmp sources",
- SHOW_STR
- IP_STR
- IGMP_STR
- IGMP_SOURCE_STR)
- {
- igmp_show_sources(vty);
- return CMD_SUCCESS;
- }
- DEFUN (show_ip_igmp_sources_retransmissions,
- show_ip_igmp_sources_retransmissions_cmd,
- "show ip igmp sources retransmissions",
- SHOW_STR
- IP_STR
- IGMP_STR
- IGMP_SOURCE_STR
- "IGMP source retransmissions\n")
- {
- igmp_show_source_retransmission(vty);
- return CMD_SUCCESS;
- }
- DEFUN (show_ip_igmp_querier,
- show_ip_igmp_querier_cmd,
- "show ip igmp querier",
- SHOW_STR
- IP_STR
- IGMP_STR
- "IGMP querier information\n")
- {
- igmp_show_querier(vty);
- return CMD_SUCCESS;
- }
- DEFUN (show_ip_pim_address,
- show_ip_pim_address_cmd,
- "show ip pim address",
- SHOW_STR
- IP_STR
- PIM_STR
- "PIM interface address\n")
- {
- show_interface_address(vty);
- return CMD_SUCCESS;
- }
- DEFUN (show_ip_pim_assert,
- show_ip_pim_assert_cmd,
- "show ip pim assert",
- SHOW_STR
- IP_STR
- PIM_STR
- "PIM interface assert\n")
- {
- pim_show_assert(vty);
- return CMD_SUCCESS;
- }
- DEFUN (show_ip_pim_assert_internal,
- show_ip_pim_assert_internal_cmd,
- "show ip pim assert-internal",
- SHOW_STR
- IP_STR
- PIM_STR
- "PIM interface internal assert state\n")
- {
- pim_show_assert_internal(vty);
- return CMD_SUCCESS;
- }
- DEFUN (show_ip_pim_assert_metric,
- show_ip_pim_assert_metric_cmd,
- "show ip pim assert-metric",
- SHOW_STR
- IP_STR
- PIM_STR
- "PIM interface assert metric\n")
- {
- pim_show_assert_metric(vty);
- return CMD_SUCCESS;
- }
- DEFUN (show_ip_pim_assert_winner_metric,
- show_ip_pim_assert_winner_metric_cmd,
- "show ip pim assert-winner-metric",
- SHOW_STR
- IP_STR
- PIM_STR
- "PIM interface assert winner metric\n")
- {
- pim_show_assert_winner_metric(vty);
- return CMD_SUCCESS;
- }
- DEFUN (show_ip_pim_dr,
- show_ip_pim_dr_cmd,
- "show ip pim designated-router",
- SHOW_STR
- IP_STR
- PIM_STR
- "PIM interface designated router\n")
- {
- pim_show_dr(vty);
- return CMD_SUCCESS;
- }
- DEFUN (show_ip_pim_hello,
- show_ip_pim_hello_cmd,
- "show ip pim hello",
- SHOW_STR
- IP_STR
- PIM_STR
- "PIM interface hello information\n")
- {
- pim_show_hello(vty);
- return CMD_SUCCESS;
- }
- DEFUN (show_ip_pim_interface,
- show_ip_pim_interface_cmd,
- "show ip pim interface",
- SHOW_STR
- IP_STR
- PIM_STR
- "PIM interface information\n")
- {
- pim_show_interfaces(vty);
- return CMD_SUCCESS;
- }
- DEFUN (show_ip_pim_join,
- show_ip_pim_join_cmd,
- "show ip pim join",
- SHOW_STR
- IP_STR
- PIM_STR
- "PIM interface join information\n")
- {
- pim_show_join(vty);
- return CMD_SUCCESS;
- }
- DEFUN (show_ip_pim_lan_prune_delay,
- show_ip_pim_lan_prune_delay_cmd,
- "show ip pim lan-prune-delay",
- SHOW_STR
- IP_STR
- PIM_STR
- "PIM neighbors LAN prune delay parameters\n")
- {
- pim_show_lan_prune_delay(vty);
- return CMD_SUCCESS;
- }
- DEFUN (show_ip_pim_local_membership,
- show_ip_pim_local_membership_cmd,
- "show ip pim local-membership",
- SHOW_STR
- IP_STR
- PIM_STR
- "PIM interface local-membership\n")
- {
- pim_show_membership(vty);
- return CMD_SUCCESS;
- }
- DEFUN (show_ip_pim_jp_override_interval,
- show_ip_pim_jp_override_interval_cmd,
- "show ip pim jp-override-interval",
- SHOW_STR
- IP_STR
- PIM_STR
- "PIM interface J/P override interval\n")
- {
- pim_show_jp_override_interval(vty);
- return CMD_SUCCESS;
- }
- DEFUN (show_ip_pim_neighbor,
- show_ip_pim_neighbor_cmd,
- "show ip pim neighbor",
- SHOW_STR
- IP_STR
- PIM_STR
- "PIM neighbor information\n")
- {
- pim_show_neighbors(vty);
- return CMD_SUCCESS;
- }
- DEFUN (show_ip_pim_secondary,
- show_ip_pim_secondary_cmd,
- "show ip pim secondary",
- SHOW_STR
- IP_STR
- PIM_STR
- "PIM neighbor addresses\n")
- {
- pim_show_neighbors_secondary(vty);
- return CMD_SUCCESS;
- }
- DEFUN (show_ip_pim_upstream,
- show_ip_pim_upstream_cmd,
- "show ip pim upstream",
- SHOW_STR
- IP_STR
- PIM_STR
- "PIM upstream information\n")
- {
- pim_show_upstream(vty);
- return CMD_SUCCESS;
- }
- DEFUN (show_ip_pim_upstream_join_desired,
- show_ip_pim_upstream_join_desired_cmd,
- "show ip pim upstream-join-desired",
- SHOW_STR
- IP_STR
- PIM_STR
- "PIM upstream join-desired\n")
- {
- pim_show_join_desired(vty);
- return CMD_SUCCESS;
- }
- DEFUN (show_ip_pim_upstream_rpf,
- show_ip_pim_upstream_rpf_cmd,
- "show ip pim upstream-rpf",
- SHOW_STR
- IP_STR
- PIM_STR
- "PIM upstream source rpf\n")
- {
- pim_show_upstream_rpf(vty);
- return CMD_SUCCESS;
- }
- DEFUN (show_ip_pim_rpf,
- show_ip_pim_rpf_cmd,
- "show ip pim rpf",
- SHOW_STR
- IP_STR
- PIM_STR
- "PIM cached source rpf information\n")
- {
- pim_show_rpf(vty);
- return CMD_SUCCESS;
- }
- static void show_multicast_interfaces(struct vty *vty)
- {
- struct listnode *node;
- struct interface *ifp;
- vty_out(vty, "%s", VTY_NEWLINE);
-
- vty_out(vty, "Interface Address ifIndex VifIndex PktsIn PktsOut BytesIn BytesOut%s",
- VTY_NEWLINE);
- for (ALL_LIST_ELEMENTS_RO(iflist, node, ifp)) {
- struct pim_interface *pim_ifp;
- struct in_addr ifaddr;
- struct sioc_vif_req vreq;
- pim_ifp = ifp->info;
-
- if (!pim_ifp)
- continue;
- memset(&vreq, 0, sizeof(vreq));
- vreq.vifi = pim_ifp->mroute_vif_index;
- if (ioctl(qpim_mroute_socket_fd, SIOCGETVIFCNT, &vreq)) {
- int e = errno;
- vty_out(vty,
- "ioctl(SIOCGETVIFCNT=%d) failure for interface %s vif_index=%d: errno=%d: %s%s",
- SIOCGETVIFCNT,
- ifp->name,
- pim_ifp->mroute_vif_index,
- e,
- strerror(e),
- VTY_NEWLINE);
- continue;
- }
- ifaddr = pim_ifp->primary_address;
- vty_out(vty, "%-9s %-15s %7d %8d %6lu %7lu %7lu %8lu%s",
- ifp->name,
- inet_ntoa(ifaddr),
- ifp->ifindex,
- pim_ifp->mroute_vif_index,
- vreq.icount,
- vreq.ocount,
- vreq.ibytes,
- vreq.obytes,
- VTY_NEWLINE);
- }
- }
- DEFUN (show_ip_multicast,
- show_ip_multicast_cmd,
- "show ip multicast",
- SHOW_STR
- IP_STR
- "Multicast global information\n")
- {
- if (PIM_MROUTE_IS_ENABLED) {
- time_t now;
- char uptime[10];
- vty_out(vty, "Mroute socket descriptor: %d%s",
- qpim_mroute_socket_fd,
- VTY_NEWLINE);
- now = pim_time_monotonic_sec();
- pim_time_uptime(uptime, sizeof(uptime), now - qpim_mroute_socket_creation);
- vty_out(vty, "Mroute socket uptime: %s%s",
- uptime,
- VTY_NEWLINE);
- }
- else {
- vty_out(vty, "Multicast disabled%s",
- VTY_NEWLINE);
- }
- vty_out(vty, "%s", VTY_NEWLINE);
- vty_out(vty, "Current highest VifIndex: %d%s",
- qpim_mroute_oif_highest_vif_index,
- VTY_NEWLINE);
- vty_out(vty, "Maximum highest VifIndex: %d%s",
- MAXVIFS - 1,
- VTY_NEWLINE);
- vty_out(vty, "%s", VTY_NEWLINE);
- vty_out(vty, "Upstream Join Timer: %d secs%s",
- qpim_t_periodic,
- VTY_NEWLINE);
- vty_out(vty, "Join/Prune Holdtime: %d secs%s",
- PIM_JP_HOLDTIME,
- VTY_NEWLINE);
- vty_out(vty, "%s", VTY_NEWLINE);
- vty_out(vty, "RPF Cache Refresh Delay: %ld msecs%s",
- qpim_rpf_cache_refresh_delay_msec,
- VTY_NEWLINE);
- vty_out(vty, "RPF Cache Refresh Timer: %ld msecs%s",
- pim_time_timer_remain_msec(qpim_rpf_cache_refresher),
- VTY_NEWLINE);
- show_multicast_interfaces(vty);
-
- return CMD_SUCCESS;
- }
- static void show_mroute(struct vty *vty)
- {
- struct listnode *node;
- struct channel_oil *c_oil;
- time_t now;
- vty_out(vty, "Proto: I=IGMP P=PIM%s%s", VTY_NEWLINE, VTY_NEWLINE);
-
- vty_out(vty, "Source Group Proto Input iVifI Output oVifI TTL Uptime %s",
- VTY_NEWLINE);
- now = pim_time_monotonic_sec();
- for (ALL_LIST_ELEMENTS_RO(qpim_channel_oil_list, node, c_oil)) {
- char group_str[100];
- char source_str[100];
- int oif_vif_index;
- pim_inet4_dump("<group?>", c_oil->oil.mfcc_mcastgrp, group_str, sizeof(group_str));
- pim_inet4_dump("<source?>", c_oil->oil.mfcc_origin, source_str, sizeof(source_str));
-
- for (oif_vif_index = 0; oif_vif_index < MAXVIFS; ++oif_vif_index) {
- struct interface *ifp_in;
- struct interface *ifp_out;
- char oif_uptime[10];
- int ttl;
- char proto[5];
- ttl = c_oil->oil.mfcc_ttls[oif_vif_index];
- if (ttl < 1)
- continue;
- ifp_in = pim_if_find_by_vif_index(c_oil->oil.mfcc_parent);
- ifp_out = pim_if_find_by_vif_index(oif_vif_index);
- pim_time_uptime(oif_uptime, sizeof(oif_uptime), now - c_oil->oif_creation[oif_vif_index]);
- proto[0] = '\0';
- if (c_oil->oif_flags[oif_vif_index] & PIM_OIF_FLAG_PROTO_PIM) {
- strcat(proto, "P");
- }
- if (c_oil->oif_flags[oif_vif_index] & PIM_OIF_FLAG_PROTO_IGMP) {
- strcat(proto, "I");
- }
- vty_out(vty, "%-15s %-15s %-5s %-5s %5d %-6s %5d %3d %8s %s",
- source_str,
- group_str,
- proto,
- ifp_in ? ifp_in->name : "<iif?>",
- c_oil->oil.mfcc_parent,
- ifp_out ? ifp_out->name : "<oif?>",
- oif_vif_index,
- ttl,
- oif_uptime,
- VTY_NEWLINE);
- }
- }
- }
- DEFUN (show_ip_mroute,
- show_ip_mroute_cmd,
- "show ip mroute",
- SHOW_STR
- IP_STR
- MROUTE_STR)
- {
- show_mroute(vty);
- return CMD_SUCCESS;
- }
- static void show_mroute_count(struct vty *vty)
- {
- struct listnode *node;
- struct channel_oil *c_oil;
- vty_out(vty, "%s", VTY_NEWLINE);
-
- vty_out(vty, "Source Group Packets Bytes WrongIf %s",
- VTY_NEWLINE);
- for (ALL_LIST_ELEMENTS_RO(qpim_channel_oil_list, node, c_oil)) {
- char group_str[100];
- char source_str[100];
- struct sioc_sg_req sgreq;
- memset(&sgreq, 0, sizeof(sgreq));
- sgreq.src = c_oil->oil.mfcc_origin;
- sgreq.grp = c_oil->oil.mfcc_mcastgrp;
- pim_inet4_dump("<group?>", c_oil->oil.mfcc_mcastgrp, group_str, sizeof(group_str));
- pim_inet4_dump("<source?>", c_oil->oil.mfcc_origin, source_str, sizeof(source_str));
- if (ioctl(qpim_mroute_socket_fd, SIOCGETSGCNT, &sgreq)) {
- int e = errno;
- vty_out(vty,
- "ioctl(SIOCGETSGCNT=%d) failure for (S,G)=(%s,%s): errno=%d: %s%s",
- SIOCGETSGCNT,
- source_str,
- group_str,
- e,
- strerror(e),
- VTY_NEWLINE);
- continue;
- }
-
- vty_out(vty, "%-15s %-15s %7ld %10ld %7ld %s",
- source_str,
- group_str,
- sgreq.pktcnt,
- sgreq.bytecnt,
- sgreq.wrong_if,
- VTY_NEWLINE);
- }
- }
- DEFUN (show_ip_mroute_count,
- show_ip_mroute_count_cmd,
- "show ip mroute count",
- SHOW_STR
- IP_STR
- MROUTE_STR
- "Route and packet count data\n")
- {
- show_mroute_count(vty);
- return CMD_SUCCESS;
- }
- DEFUN (show_ip_route,
- show_ip_route_cmd,
- "show ip route A.B.C.D",
- SHOW_STR
- IP_STR
- ROUTE_STR
- "Unicast address\n")
- {
- struct in_addr addr;
- const char *addr_str;
- struct pim_nexthop nexthop;
- char nexthop_addr_str[100];
- int result;
- addr_str = argv[0];
- result = inet_pton(AF_INET, addr_str, &addr);
- if (result <= 0) {
- vty_out(vty, "Bad unicast address %s: errno=%d: %s%s",
- addr_str, errno, strerror(errno), VTY_NEWLINE);
- return CMD_WARNING;
- }
- if (pim_nexthop_lookup(&nexthop, addr)) {
- vty_out(vty, "Failure querying RIB nexthop for unicast address %s%s",
- addr_str, VTY_NEWLINE);
- return CMD_WARNING;
- }
- vty_out(vty, "Address NextHop Interface Metric Preference%s",
- VTY_NEWLINE);
- pim_inet4_dump("<nexthop?>", nexthop.mrib_nexthop_addr,
- nexthop_addr_str, sizeof(nexthop_addr_str));
- vty_out(vty, "%-15s %-15s %-9s %6d %10d%s",
- addr_str,
- nexthop_addr_str,
- nexthop.interface ? nexthop.interface->name : "<ifname?>",
- nexthop.mrib_route_metric,
- nexthop.mrib_metric_preference,
- VTY_NEWLINE);
- return CMD_SUCCESS;
- }
- static void mroute_add_all()
- {
- struct listnode *node;
- struct channel_oil *c_oil;
- for (ALL_LIST_ELEMENTS_RO(qpim_channel_oil_list, node, c_oil)) {
- if (pim_mroute_add(&c_oil->oil)) {
- /* just log warning */
- char source_str[100];
- char group_str[100];
- pim_inet4_dump("<source?>", c_oil->oil.mfcc_origin, source_str, sizeof(source_str));
- pim_inet4_dump("<group?>", c_oil->oil.mfcc_mcastgrp, group_str, sizeof(group_str));
- zlog_warn("%s %s: (S,G)=(%s,%s) failure writing MFC",
- __FILE__, __PRETTY_FUNCTION__,
- source_str, group_str);
- }
- }
- }
- static void mroute_del_all()
- {
- struct listnode *node;
- struct channel_oil *c_oil;
- for (ALL_LIST_ELEMENTS_RO(qpim_channel_oil_list, node, c_oil)) {
- if (pim_mroute_del(&c_oil->oil)) {
- /* just log warning */
- char source_str[100];
- char group_str[100];
- pim_inet4_dump("<source?>", c_oil->oil.mfcc_origin, source_str, sizeof(source_str));
- pim_inet4_dump("<group?>", c_oil->oil.mfcc_mcastgrp, group_str, sizeof(group_str));
- zlog_warn("%s %s: (S,G)=(%s,%s) failure clearing MFC",
- __FILE__, __PRETTY_FUNCTION__,
- source_str, group_str);
- }
- }
- }
- DEFUN (ip_multicast_routing,
- ip_multicast_routing_cmd,
- PIM_CMD_IP_MULTICAST_ROUTING,
- IP_STR
- "Enable IP multicast forwarding\n")
- {
- pim_mroute_socket_enable();
- pim_if_add_vif_all();
- mroute_add_all();
- return CMD_SUCCESS;
- }
- DEFUN (no_ip_multicast_routing,
- no_ip_multicast_routing_cmd,
- PIM_CMD_NO " " PIM_CMD_IP_MULTICAST_ROUTING,
- NO_STR
- IP_STR
- "Global IP configuration subcommands\n"
- "Enable IP multicast forwarding\n")
- {
- mroute_del_all();
- pim_if_del_vif_all();
- pim_mroute_socket_disable();
- return CMD_SUCCESS;
- }
- DEFUN (interface_ip_igmp,
- interface_ip_igmp_cmd,
- "ip igmp",
- IP_STR
- IFACE_IGMP_STR)
- {
- struct interface *ifp;
- struct pim_interface *pim_ifp;
- ifp = vty->index;
- pim_ifp = ifp->info;
- if (!pim_ifp) {
- pim_ifp = pim_if_new(ifp, 1 /* igmp=true */, 0 /* pim=false */);
- if (!pim_ifp) {
- vty_out(vty, "Could not enable IGMP on interface %s%s",
- ifp->name, VTY_NEWLINE);
- return CMD_WARNING;
- }
- }
- else {
- PIM_IF_DO_IGMP(pim_ifp->options);
- }
- pim_if_addr_add_all(ifp);
- pim_if_membership_refresh(ifp);
- return CMD_SUCCESS;
- }
- DEFUN (interface_no_ip_igmp,
- interface_no_ip_igmp_cmd,
- "no ip igmp",
- NO_STR
- IP_STR
- IFACE_IGMP_STR)
- {
- struct interface *ifp;
- struct pim_interface *pim_ifp;
- ifp = vty->index;
- pim_ifp = ifp->info;
- if (!pim_ifp)
- return CMD_SUCCESS;
- PIM_IF_DONT_IGMP(pim_ifp->options);
- pim_if_membership_clear(ifp);
- pim_if_addr_del_all(ifp);
- if (!PIM_IF_TEST_PIM(pim_ifp->options)) {
- pim_if_delete(ifp);
- }
- return CMD_SUCCESS;
- }
- DEFUN (interface_ip_igmp_join,
- interface_ip_igmp_join_cmd,
- "ip igmp join A.B.C.D A.B.C.D",
- IP_STR
- IFACE_IGMP_STR
- "IGMP join multicast group\n"
- "Multicast group address\n"
- "Source address\n")
- {
- struct interface *ifp;
- const char *group_str;
- const char *source_str;
- struct in_addr group_addr;
- struct in_addr source_addr;
- int result;
- ifp = vty->index;
- /* Group address */
- group_str = argv[0];
- result = inet_pton(AF_INET, group_str, &group_addr);
- if (result <= 0) {
- vty_out(vty, "Bad group address %s: errno=%d: %s%s",
- group_str, errno, strerror(errno), VTY_NEWLINE);
- return CMD_WARNING;
- }
- /* Source address */
- source_str = argv[1];
- result = inet_pton(AF_INET, source_str, &source_addr);
- if (result <= 0) {
- vty_out(vty, "Bad source address %s: errno=%d: %s%s",
- source_str, errno, strerror(errno), VTY_NEWLINE);
- return CMD_WARNING;
- }
- result = pim_if_igmp_join_add(ifp, group_addr, source_addr);
- if (result) {
- vty_out(vty, "%% Failure joining IGMP group %s source %s on interface %s: %d%s",
- group_str, source_str, ifp->name, result, VTY_NEWLINE);
- return CMD_WARNING;
- }
- return CMD_SUCCESS;
- }
- DEFUN (interface_no_ip_igmp_join,
- interface_no_ip_igmp_join_cmd,
- "no ip igmp join A.B.C.D A.B.C.D",
- NO_STR
- IP_STR
- IFACE_IGMP_STR
- "IGMP join multicast group\n"
- "Multicast group address\n"
- "Source address\n")
- {
- struct interface *ifp;
- const char *group_str;
- const char *source_str;
- struct in_addr group_addr;
- struct in_addr source_addr;
- int result;
- ifp = vty->index;
- /* Group address */
- group_str = argv[0];
- result = inet_pton(AF_INET, group_str, &group_addr);
- if (result <= 0) {
- vty_out(vty, "Bad group address %s: errno=%d: %s%s",
- group_str, errno, strerror(errno), VTY_NEWLINE);
- return CMD_WARNING;
- }
- /* Source address */
- source_str = argv[1];
- result = inet_pton(AF_INET, source_str, &source_addr);
- if (result <= 0) {
- vty_out(vty, "Bad source address %s: errno=%d: %s%s",
- source_str, errno, strerror(errno), VTY_NEWLINE);
- return CMD_WARNING;
- }
- result = pim_if_igmp_join_del(ifp, group_addr, source_addr);
- if (result) {
- vty_out(vty, "%% Failure leaving IGMP group %s source %s on interface %s: %d%s",
- group_str, source_str, ifp->name, result, VTY_NEWLINE);
- return CMD_WARNING;
- }
- return CMD_SUCCESS;
- }
- /*
- CLI reconfiguration affects the interface level (struct pim_interface).
- This function propagates the reconfiguration to every active socket
- for that interface.
- */
- static void igmp_sock_query_interval_reconfig(struct igmp_sock *igmp)
- {
- struct interface *ifp;
- struct pim_interface *pim_ifp;
- zassert(igmp);
- /* other querier present? */
- if (igmp->t_other_querier_timer)
- return;
- /* this is the querier */
- zassert(igmp->interface);
- zassert(igmp->interface->info);
- ifp = igmp->interface;
- pim_ifp = ifp->info;
- if (PIM_DEBUG_IGMP_TRACE) {
- char ifaddr_str[100];
- pim_inet4_dump("<ifaddr?>", igmp->ifaddr, ifaddr_str, sizeof(ifaddr_str));
- zlog_debug("%s: Querier %s on %s reconfig query_interval=%d",
- __PRETTY_FUNCTION__,
- ifaddr_str,
- ifp->name,
- pim_ifp->igmp_default_query_interval);
- }
- /*
- igmp_startup_mode_on() will reset QQI:
- igmp->querier_query_interval = pim_ifp->igmp_default_query_interval;
- */
- igmp_startup_mode_on(igmp);
- }
- static void igmp_sock_query_reschedule(struct igmp_sock *igmp)
- {
- if (igmp->t_igmp_query_timer) {
- /* other querier present */
- zassert(igmp->t_igmp_query_timer);
- zassert(!igmp->t_other_querier_timer);
- pim_igmp_general_query_off(igmp);
- pim_igmp_general_query_on(igmp);
- zassert(igmp->t_igmp_query_timer);
- zassert(!igmp->t_other_querier_timer);
- }
- else {
- /* this is the querier */
- zassert(!igmp->t_igmp_query_timer);
- zassert(igmp->t_other_querier_timer);
- pim_igmp_other_querier_timer_off(igmp);
- pim_igmp_other_querier_timer_on(igmp);
- zassert(!igmp->t_igmp_query_timer);
- zassert(igmp->t_other_querier_timer);
- }
- }
- static void change_query_interval(struct pim_interface *pim_ifp,
- int query_interval)
- {
- struct listnode *sock_node;
- struct igmp_sock *igmp;
- pim_ifp->igmp_default_query_interval = query_interval;
- for (ALL_LIST_ELEMENTS_RO(pim_ifp->igmp_socket_list, sock_node, igmp)) {
- igmp_sock_query_interval_reconfig(igmp);
- igmp_sock_query_reschedule(igmp);
- }
- }
- static void change_query_max_response_time(struct pim_interface *pim_ifp,
- int query_max_response_time_dsec)
- {
- struct listnode *sock_node;
- struct igmp_sock *igmp;
- pim_ifp->igmp_query_max_response_time_dsec = query_max_response_time_dsec;
- /*
- Below we modify socket/group/source timers in order to quickly
- reflect the change. Otherwise, those timers would eventually catch
- up.
- */
- /* scan all sockets */
- for (ALL_LIST_ELEMENTS_RO(pim_ifp->igmp_socket_list, sock_node, igmp)) {
- struct listnode *grp_node;
- struct igmp_group *grp;
- /* reschedule socket general query */
- igmp_sock_query_reschedule(igmp);
- /* scan socket groups */
- for (ALL_LIST_ELEMENTS_RO(igmp->igmp_group_list, grp_node, grp)) {
- struct listnode *src_node;
- struct igmp_source *src;
- /* reset group timers for groups in EXCLUDE mode */
- if (grp->group_filtermode_isexcl) {
- igmp_group_reset_gmi(grp);
- }
- /* scan group sources */
- for (ALL_LIST_ELEMENTS_RO(grp->group_source_list, src_node, src)) {
- /* reset source timers for sources with running timers */
- if (src->t_source_timer) {
- igmp_source_reset_gmi(igmp, grp, src);
- }
- }
- }
- }
- }
- #define IGMP_QUERY_INTERVAL_MIN (1)
- #define IGMP_QUERY_INTERVAL_MAX (1800)
- DEFUN (interface_ip_igmp_query_interval,
- interface_ip_igmp_query_interval_cmd,
- PIM_CMD_IP_IGMP_QUERY_INTERVAL " <1-1800>",
- IP_STR
- IFACE_IGMP_STR
- IFACE_IGMP_QUERY_INTERVAL_STR
- "Query interval in seconds\n")
- {
- struct interface *ifp;
- struct pim_interface *pim_ifp;
- int query_interval;
- int query_interval_dsec;
- ifp = vty->index;
- pim_ifp = ifp->info;
- if (!pim_ifp) {
- vty_out(vty,
- "IGMP not enabled on interface %s. Please enable IGMP first.%s",
- ifp->name,
- VTY_NEWLINE);
- return CMD_WARNING;
- }
- query_interval = atoi(argv[0]);
- query_interval_dsec = 10 * query_interval;
- /*
- It seems we don't need to check bounds since command.c does it
- already, but we verify them anyway for extra safety.
- */
- if (query_interval < IGMP_QUERY_INTERVAL_MIN) {
- vty_out(vty, "General query interval %d lower than minimum %d%s",
- query_interval,
- IGMP_QUERY_INTERVAL_MIN,
- VTY_NEWLINE);
- return CMD_WARNING;
- }
- if (query_interval > IGMP_QUERY_INTERVAL_MAX) {
- vty_out(vty, "General query interval %d higher than maximum %d%s",
- query_interval,
- IGMP_QUERY_INTERVAL_MAX,
- VTY_NEWLINE);
- return CMD_WARNING;
- }
- if (query_interval_dsec <= pim_ifp->igmp_query_max_response_time_dsec) {
- vty_out(vty,
- "Can't set general query interval %d dsec <= query max response time %d dsec.%s",
- query_interval_dsec, pim_ifp->igmp_query_max_response_time_dsec,
- VTY_NEWLINE);
- return CMD_WARNING;
- }
- change_query_interval(pim_ifp, query_interval);
- return CMD_SUCCESS;
- }
- DEFUN (interface_no_ip_igmp_query_interval,
- interface_no_ip_igmp_query_interval_cmd,
- PIM_CMD_NO " " PIM_CMD_IP_IGMP_QUERY_INTERVAL,
- NO_STR
- IP_STR
- IFACE_IGMP_STR
- IFACE_IGMP_QUERY_INTERVAL_STR)
- {
- struct interface *ifp;
- struct pim_interface *pim_ifp;
- int default_query_interval_dsec;
- ifp = vty->index;
- pim_ifp = ifp->info;
- if (!pim_ifp)
- return CMD_SUCCESS;
- default_query_interval_dsec = IGMP_GENERAL_QUERY_INTERVAL * 10;
- if (default_query_interval_dsec <= pim_ifp->igmp_query_max_response_time_dsec) {
- vty_out(vty,
- "Can't set default general query interval %d dsec <= query max response time %d dsec.%s",
- default_query_interval_dsec, pim_ifp->igmp_query_max_response_time_dsec,
- VTY_NEWLINE);
- return CMD_WARNING;
- }
- change_query_interval(pim_ifp, IGMP_GENERAL_QUERY_INTERVAL);
- return CMD_SUCCESS;
- }
- #define IGMP_QUERY_MAX_RESPONSE_TIME_MIN (1)
- #define IGMP_QUERY_MAX_RESPONSE_TIME_MAX (25)
- DEFUN (interface_ip_igmp_query_max_response_time,
- interface_ip_igmp_query_max_response_time_cmd,
- PIM_CMD_IP_IGMP_QUERY_MAX_RESPONSE_TIME " <1-25>",
- IP_STR
- IFACE_IGMP_STR
- IFACE_IGMP_QUERY_MAX_RESPONSE_TIME_STR
- "Query response value in seconds\n")
- {
- struct interface *ifp;
- struct pim_interface *pim_ifp;
- int query_max_response_time;
- ifp = vty->index;
- pim_ifp = ifp->info;
- if (!pim_ifp) {
- vty_out(vty,
- "IGMP not enabled on interface %s. Please enable IGMP first.%s",
- ifp->name,
- VTY_NEWLINE);
- return CMD_WARNING;
- }
- query_max_response_time = atoi(argv[0]);
- /*
- It seems we don't need to check bounds since command.c does it
- already, but we verify them anyway for extra safety.
- */
- if (query_max_response_time < IGMP_QUERY_MAX_RESPONSE_TIME_MIN) {
- vty_out(vty, "Query max response time %d sec lower than minimum %d sec%s",
- query_max_response_time,
- IGMP_QUERY_MAX_RESPONSE_TIME_MIN,
- VTY_NEWLINE);
- return CMD_WARNING;
- }
- if (query_max_response_time > IGMP_QUERY_MAX_RESPONSE_TIME_MAX) {
- vty_out(vty, "Query max response time %d sec higher than maximum %d sec%s",
- query_max_response_time,
- IGMP_QUERY_MAX_RESPONSE_TIME_MAX,
- VTY_NEWLINE);
- return CMD_WARNING;
- }
- if (query_max_response_time >= pim_ifp->igmp_default_query_interval) {
- vty_out(vty,
- "Can't set query max response time %d sec >= general query interval %d sec%s",
- query_max_response_time, pim_ifp->igmp_default_query_interval,
- VTY_NEWLINE);
- return CMD_WARNING;
- }
- change_query_max_response_time(pim_ifp, 10 * query_max_response_time);
- return CMD_SUCCESS;
- }
- DEFUN (interface_no_ip_igmp_query_max_response_time,
- interface_no_ip_igmp_query_max_response_time_cmd,
- PIM_CMD_NO " " PIM_CMD_IP_IGMP_QUERY_MAX_RESPONSE_TIME,
- NO_STR
- IP_STR
- IFACE_IGMP_STR
- IFACE_IGMP_QUERY_MAX_RESPONSE_TIME_STR)
- {
- struct interface *ifp;
- struct pim_interface *pim_ifp;
- int default_query_interval_dsec;
- ifp = vty->index;
- pim_ifp = ifp->info;
- if (!pim_ifp)
- return CMD_SUCCESS;
- default_query_interval_dsec = 10 * pim_ifp->igmp_default_query_interval;
- if (IGMP_QUERY_MAX_RESPONSE_TIME_DSEC >= default_query_interval_dsec) {
- vty_out(vty,
- "Can't set default query max response time %d dsec >= general query interval %d dsec.%s",
- IGMP_QUERY_MAX_RESPONSE_TIME_DSEC, default_query_interval_dsec,
- VTY_NEWLINE);
- return CMD_WARNING;
- }
- change_query_max_response_time(pim_ifp, IGMP_QUERY_MAX_RESPONSE_TIME_DSEC);
- return CMD_SUCCESS;
- }
- #define IGMP_QUERY_MAX_RESPONSE_TIME_MIN_DSEC (10)
- #define IGMP_QUERY_MAX_RESPONSE_TIME_MAX_DSEC (250)
- DEFUN (interface_ip_igmp_query_max_response_time_dsec,
- interface_ip_igmp_query_max_response_time_dsec_cmd,
- PIM_CMD_IP_IGMP_QUERY_MAX_RESPONSE_TIME_DSEC " <10-250>",
- IP_STR
- IFACE_IGMP_STR
- IFACE_IGMP_QUERY_MAX_RESPONSE_TIME_DSEC_STR
- "Query response value in deciseconds\n")
- {
- struct interface *ifp;
- struct pim_interface *pim_ifp;
- int query_max_response_time_dsec;
- int default_query_interval_dsec;
- ifp = vty->index;
- pim_ifp = ifp->info;
- if (!pim_ifp) {
- vty_out(vty,
- "IGMP not enabled on interface %s. Please enable IGMP first.%s",
- ifp->name,
- VTY_NEWLINE);
- return CMD_WARNING;
- }
- query_max_response_time_dsec = atoi(argv[0]);
- /*
- It seems we don't need to check bounds since command.c does it
- already, but we verify them anyway for extra safety.
- */
- if (query_max_response_time_dsec < IGMP_QUERY_MAX_RESPONSE_TIME_MIN_DSEC) {
- vty_out(vty, "Query max response time %d dsec lower than minimum %d dsec%s",
- query_max_response_time_dsec,
- IGMP_QUERY_MAX_RESPONSE_TIME_MIN_DSEC,
- VTY_NEWLINE);
- return CMD_WARNING;
- }
- if (query_max_response_time_dsec > IGMP_QUERY_MAX_RESPONSE_TIME_MAX_DSEC) {
- vty_out(vty, "Query max response time %d dsec higher than maximum %d dsec%s",
- query_max_response_time_dsec,
- IGMP_QUERY_MAX_RESPONSE_TIME_MAX_DSEC,
- VTY_NEWLINE);
- return CMD_WARNING;
- }
- default_query_interval_dsec = 10 * pim_ifp->igmp_default_query_interval;
- if (query_max_response_time_dsec >= default_query_interval_dsec) {
- vty_out(vty,
- "Can't set query max response time %d dsec >= general query interval %d dsec%s",
- query_max_response_time_dsec, default_query_interval_dsec,
- VTY_NEWLINE);
- return CMD_WARNING;
- }
- change_query_max_response_time(pim_ifp, query_max_response_time_dsec);
- return CMD_SUCCESS;
- }
- DEFUN (interface_no_ip_igmp_query_max_response_time_dsec,
- interface_no_ip_igmp_query_max_response_time_dsec_cmd,
- PIM_CMD_NO " " PIM_CMD_IP_IGMP_QUERY_MAX_RESPONSE_TIME_DSEC,
- NO_STR
- IP_STR
- IFACE_IGMP_STR
- IFACE_IGMP_QUERY_MAX_RESPONSE_TIME_DSEC_STR)
- {
- struct interface *ifp;
- struct pim_interface *pim_ifp;
- int default_query_interval_dsec;
- ifp = vty->index;
- pim_ifp = ifp->info;
- if (!pim_ifp)
- return CMD_SUCCESS;
- default_query_interval_dsec = 10 * pim_ifp->igmp_default_query_interval;
- if (IGMP_QUERY_MAX_RESPONSE_TIME_DSEC >= default_query_interval_dsec) {
- vty_out(vty,
- "Can't set default query max response time %d dsec >= general query interval %d dsec.%s",
- IGMP_QUERY_MAX_RESPONSE_TIME_DSEC, default_query_interval_dsec,
- VTY_NEWLINE);
- return CMD_WARNING;
- }
- change_query_max_response_time(pim_ifp, IGMP_QUERY_MAX_RESPONSE_TIME_DSEC);
- return CMD_SUCCESS;
- }
- DEFUN (interface_ip_pim_ssm,
- interface_ip_pim_ssm_cmd,
- "ip pim ssm",
- IP_STR
- PIM_STR
- IFACE_PIM_STR)
- {
- struct interface *ifp;
- struct pim_interface *pim_ifp;
- ifp = vty->index;
- pim_ifp = ifp->info;
- if (!pim_ifp) {
- pim_ifp = pim_if_new(ifp, 0 /* igmp=false */, 1 /* pim=true */);
- if (!pim_ifp) {
- vty_out(vty, "Could not enable PIM on interface%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
- }
- else {
- PIM_IF_DO_PIM(pim_ifp->options);
- }
- pim_if_addr_add_all(ifp);
- pim_if_membership_refresh(ifp);
- return CMD_SUCCESS;
- }
- DEFUN (interface_no_ip_pim_ssm,
- interface_no_ip_pim_ssm_cmd,
- "no ip pim ssm",
- NO_STR
- IP_STR
- PIM_STR
- IFACE_PIM_STR)
- {
- struct interface *ifp;
- struct pim_interface *pim_ifp;
- ifp = vty->index;
- pim_ifp = ifp->info;
- if (!pim_ifp)
- return CMD_SUCCESS;
- PIM_IF_DONT_PIM(pim_ifp->options);
- pim_if_membership_clear(ifp);
- /*
- pim_if_addr_del_all() removes all sockets from
- pim_ifp->igmp_socket_list.
- */
- pim_if_addr_del_all(ifp);
- /*
- pim_sock_delete() removes all neighbors from
- pim_ifp->pim_neighbor_list.
- */
- pim_sock_delete(ifp, "pim unconfigured on interface");
- if (!PIM_IF_TEST_IGMP(pim_ifp->options)) {
- pim_if_delete(ifp);
- }
- return CMD_SUCCESS;
- }
- DEFUN (debug_igmp,
- debug_igmp_cmd,
- "debug igmp",
- DEBUG_STR
- DEBUG_IGMP_STR)
- {
- PIM_DO_DEBUG_IGMP_EVENTS;
- PIM_DO_DEBUG_IGMP_PACKETS;
- PIM_DO_DEBUG_IGMP_TRACE;
- return CMD_SUCCESS;
- }
- DEFUN (no_debug_igmp,
- no_debug_igmp_cmd,
- "no debug igmp",
- NO_STR
- DEBUG_STR
- DEBUG_IGMP_STR)
- {
- PIM_DONT_DEBUG_IGMP_EVENTS;
- PIM_DONT_DEBUG_IGMP_PACKETS;
- PIM_DONT_DEBUG_IGMP_TRACE;
- return CMD_SUCCESS;
- }
- ALIAS (no_debug_igmp,
- undebug_igmp_cmd,
- "undebug igmp",
- UNDEBUG_STR
- DEBUG_IGMP_STR)
- DEFUN (debug_igmp_events,
- debug_igmp_events_cmd,
- "debug igmp events",
- DEBUG_STR
- DEBUG_IGMP_STR
- DEBUG_IGMP_EVENTS_STR)
- {
- PIM_DO_DEBUG_IGMP_EVENTS;
- return CMD_SUCCESS;
- }
- DEFUN (no_debug_igmp_events,
- no_debug_igmp_events_cmd,
- "no debug igmp events",
- NO_STR
- DEBUG_STR
- DEBUG_IGMP_STR
- DEBUG_IGMP_EVENTS_STR)
- {
- PIM_DONT_DEBUG_IGMP_EVENTS;
- return CMD_SUCCESS;
- }
- ALIAS (no_debug_igmp_events,
- undebug_igmp_events_cmd,
- "undebug igmp events",
- UNDEBUG_STR
- DEBUG_IGMP_STR
- DEBUG_IGMP_EVENTS_STR)
- DEFUN (debug_igmp_packets,
- debug_igmp_packets_cmd,
- "debug igmp packets",
- DEBUG_STR
- DEBUG_IGMP_STR
- DEBUG_IGMP_PACKETS_STR)
- {
- PIM_DO_DEBUG_IGMP_PACKETS;
- return CMD_SUCCESS;
- }
- DEFUN (no_debug_igmp_packets,
- no_debug_igmp_packets_cmd,
- "no debug igmp packets",
- NO_STR
- DEBUG_STR
- DEBUG_IGMP_STR
- DEBUG_IGMP_PACKETS_STR)
- {
- PIM_DONT_DEBUG_IGMP_PACKETS;
- return CMD_SUCCESS;
- }
- ALIAS (no_debug_igmp_packets,
- undebug_igmp_packets_cmd,
- "undebug igmp packets",
- UNDEBUG_STR
- DEBUG_IGMP_STR
- DEBUG_IGMP_PACKETS_STR)
- DEFUN (debug_igmp_trace,
- debug_igmp_trace_cmd,
- "debug igmp trace",
- DEBUG_STR
- DEBUG_IGMP_STR
- DEBUG_IGMP_TRACE_STR)
- {
- PIM_DO_DEBUG_IGMP_TRACE;
- return CMD_SUCCESS;
- }
- DEFUN (no_debug_igmp_trace,
- no_debug_igmp_trace_cmd,
- "no debug igmp trace",
- NO_STR
- DEBUG_STR
- DEBUG_IGMP_STR
- DEBUG_IGMP_TRACE_STR)
- {
- PIM_DONT_DEBUG_IGMP_TRACE;
- return CMD_SUCCESS;
- }
- ALIAS (no_debug_igmp_trace,
- undebug_igmp_trace_cmd,
- "undebug igmp trace",
- UNDEBUG_STR
- DEBUG_IGMP_STR
- DEBUG_IGMP_TRACE_STR)
- DEFUN (debug_pim,
- debug_pim_cmd,
- "debug pim",
- DEBUG_STR
- DEBUG_PIM_STR)
- {
- PIM_DO_DEBUG_PIM_EVENTS;
- PIM_DO_DEBUG_PIM_PACKETS;
- PIM_DO_DEBUG_PIM_TRACE;
- return CMD_SUCCESS;
- }
- DEFUN (no_debug_pim,
- no_debug_pim_cmd,
- "no debug pim",
- NO_STR
- DEBUG_STR
- DEBUG_PIM_STR)
- {
- PIM_DONT_DEBUG_PIM_EVENTS;
- PIM_DONT_DEBUG_PIM_PACKETS;
- PIM_DONT_DEBUG_PIM_TRACE;
- return CMD_SUCCESS;
- }
- ALIAS (no_debug_pim,
- undebug_pim_cmd,
- "undebug pim",
- UNDEBUG_STR
- DEBUG_PIM_STR)
- DEFUN (debug_pim_events,
- debug_pim_events_cmd,
- "debug pim events",
- DEBUG_STR
- DEBUG_PIM_STR
- DEBUG_PIM_EVENTS_STR)
- {
- PIM_DO_DEBUG_PIM_EVENTS;
- return CMD_SUCCESS;
- }
- DEFUN (no_debug_pim_events,
- no_debug_pim_events_cmd,
- "no debug pim events",
- NO_STR
- DEBUG_STR
- DEBUG_PIM_STR
- DEBUG_PIM_EVENTS_STR)
- {
- PIM_DONT_DEBUG_PIM_EVENTS;
- return CMD_SUCCESS;
- }
- ALIAS (no_debug_pim_events,
- undebug_pim_events_cmd,
- "undebug pim events",
- UNDEBUG_STR
- DEBUG_PIM_STR
- DEBUG_PIM_EVENTS_STR)
- DEFUN (debug_pim_packets,
- debug_pim_packets_cmd,
- "debug pim packets",
- DEBUG_STR
- DEBUG_PIM_STR
- DEBUG_PIM_PACKETS_STR)
- {
- PIM_DO_DEBUG_PIM_PACKETS;
- return CMD_SUCCESS;
- }
- DEFUN (no_debug_pim_packets,
- no_debug_pim_packets_cmd,
- "no debug pim packets",
- NO_STR
- DEBUG_STR
- DEBUG_PIM_STR
- DEBUG_PIM_PACKETS_STR)
- {
- PIM_DONT_DEBUG_PIM_PACKETS;
- return CMD_SUCCESS;
- }
- ALIAS (no_debug_pim_packets,
- undebug_pim_packets_cmd,
- "undebug pim packets",
- UNDEBUG_STR
- DEBUG_PIM_STR
- DEBUG_PIM_PACKETS_STR)
- DEFUN (debug_pim_trace,
- debug_pim_trace_cmd,
- "debug pim trace",
- DEBUG_STR
- DEBUG_PIM_STR
- DEBUG_PIM_TRACE_STR)
- {
- PIM_DO_DEBUG_PIM_TRACE;
- return CMD_SUCCESS;
- }
- DEFUN (no_debug_pim_trace,
- no_debug_pim_trace_cmd,
- "no debug pim trace",
- NO_STR
- DEBUG_STR
- DEBUG_PIM_STR
- DEBUG_PIM_TRACE_STR)
- {
- PIM_DONT_DEBUG_PIM_TRACE;
- return CMD_SUCCESS;
- }
- ALIAS (no_debug_pim_trace,
- undebug_pim_trace_cmd,
- "undebug pim trace",
- UNDEBUG_STR
- DEBUG_PIM_STR
- DEBUG_PIM_TRACE_STR)
- DEFUN (debug_pim_zebra,
- debug_pim_zebra_cmd,
- "debug pim zebra",
- DEBUG_STR
- DEBUG_PIM_STR
- DEBUG_PIM_ZEBRA_STR)
- {
- PIM_DO_DEBUG_ZEBRA;
- return CMD_SUCCESS;
- }
- DEFUN (no_debug_pim_zebra,
- no_debug_pim_zebra_cmd,
- "no debug pim zebra",
- NO_STR
- DEBUG_STR
- DEBUG_PIM_STR
- DEBUG_PIM_ZEBRA_STR)
- {
- PIM_DONT_DEBUG_ZEBRA;
- return CMD_SUCCESS;
- }
- ALIAS (no_debug_pim_zebra,
- undebug_pim_zebra_cmd,
- "undebug pim zebra",
- UNDEBUG_STR
- DEBUG_PIM_STR
- DEBUG_PIM_ZEBRA_STR)
- DEFUN (show_debugging,
- show_debugging_cmd,
- "show debugging",
- SHOW_STR
- "State of each debugging option\n")
- {
- pim_debug_config_write(vty);
- return CMD_SUCCESS;
- }
- static struct igmp_sock *find_igmp_sock_by_fd(int fd)
- {
- struct listnode *ifnode;
- struct interface *ifp;
- /* scan all interfaces */
- for (ALL_LIST_ELEMENTS_RO(iflist, ifnode, ifp)) {
- struct pim_interface *pim_ifp;
- struct igmp_sock *igmp;
-
- if (!ifp->info)
- continue;
- pim_ifp = ifp->info;
- /* lookup igmp socket under current interface */
- igmp = igmp_sock_lookup_by_fd(pim_ifp->igmp_socket_list, fd);
- if (igmp)
- return igmp;
- }
- return 0;
- }
- DEFUN (test_igmp_receive_report,
- test_igmp_receive_report_cmd,
- "test igmp receive report <0-65535> A.B.C.D <1-6> .LINE",
- "Test\n"
- "Test IGMP protocol\n"
- "Test IGMP message\n"
- "Test IGMP report\n"
- "Socket\n"
- "IGMP group address\n"
- "Record type\n"
- "Sources\n")
- {
- char buf[1000];
- char *igmp_msg;
- struct ip *ip_hdr;
- size_t ip_hlen; /* ip header length in bytes */
- int ip_msg_len;
- int igmp_msg_len;
- const char *socket;
- int socket_fd;
- const char *grp_str;
- struct in_addr grp_addr;
- const char *record_type_str;
- int record_type;
- const char *src_str;
- int result;
- struct igmp_sock *igmp;
- char *group_record;
- int num_sources;
- struct in_addr *sources;
- struct in_addr *src_addr;
- int argi;
- socket = argv[0];
- socket_fd = atoi(socket);
- igmp = find_igmp_sock_by_fd(socket_fd);
- if (!igmp) {
- vty_out(vty, "Could not find IGMP socket %s: fd=%d%s",
- socket, socket_fd, VTY_NEWLINE);
- return CMD_WARNING;
- }
- grp_str = argv[1];
- result = inet_pton(AF_INET, grp_str, &grp_addr);
- if (result <= 0) {
- vty_out(vty, "Bad group address %s: errno=%d: %s%s",
- grp_str, errno, strerror(errno), VTY_NEWLINE);
- return CMD_WARNING;
- }
- record_type_str = argv[2];
- record_type = atoi(record_type_str);
- /*
- Tweak IP header
- */
- ip_hdr = (struct ip *) buf;
- ip_hdr->ip_p = PIM_IP_PROTO_IGMP;
- ip_hlen = PIM_IP_HEADER_MIN_LEN; /* ip header length in bytes */
- ip_hdr->ip_hl = ip_hlen >> 2; /* ip header length in 4-byte words */
- ip_hdr->ip_src = igmp->ifaddr;
- ip_hdr->ip_dst = igmp->ifaddr;
- /*
- Build IGMP v3 report message
- */
- igmp_msg = buf + ip_hlen;
- group_record = igmp_msg + IGMP_V3_REPORT_GROUPPRECORD_OFFSET;
- *igmp_msg = PIM_IGMP_V3_MEMBERSHIP_REPORT; /* type */
- *(uint16_t *) (igmp_msg + IGMP_V3_CHECKSUM_OFFSET) = 0; /* for computing checksum */
- *(uint16_t *) (igmp_msg + IGMP_V3_REPORT_NUMGROUPS_OFFSET) = htons(1); /* one group record */
- *(uint8_t *) (group_record + IGMP_V3_GROUP_RECORD_TYPE_OFFSET) = record_type;
- *(struct in_addr *)(group_record + IGMP_V3_GROUP_RECORD_GROUP_OFFSET) = grp_addr;
- /* Scan LINE sources */
- sources = (struct in_addr *) (group_record + IGMP_V3_GROUP_RECORD_SOURCE_OFFSET);
- src_addr = sources;
- for (argi = 3; argi < argc; ++argi,++src_addr) {
- src_str = argv[argi];
- result = inet_pton(AF_INET, src_str, src_addr);
- if (result <= 0) {
- vty_out(vty, "Bad source address %s: errno=%d: %s%s",
- src_str, errno, strerror(errno), VTY_NEWLINE);
- return CMD_WARNING;
- }
- }
- num_sources = src_addr - sources;
- *(uint16_t *)(group_record + IGMP_V3_GROUP_RECORD_NUMSOURCES_OFFSET) = htons(num_sources);
- igmp_msg_len = IGMP_V3_MSG_MIN_SIZE + (num_sources << 4); /* v3 report for one single group record */
- /* compute checksum */
- *(uint16_t *)(igmp_msg + IGMP_V3_CHECKSUM_OFFSET) = pim_inet_checksum(igmp_msg, igmp_msg_len);
- /* "receive" message */
- ip_msg_len = ip_hlen + igmp_msg_len;
- result = pim_igmp_packet(igmp, buf, ip_msg_len);
- if (result) {
- vty_out(vty, "pim_igmp_packet(len=%d) returned: %d%s",
- ip_msg_len, result, VTY_NEWLINE);
- return CMD_WARNING;
- }
- return CMD_SUCCESS;
- }
- DEFUN (test_pim_receive_hello,
- test_pim_receive_hello_cmd,
- "test pim receive hello INTERFACE A.B.C.D <0-65535> <0-65535> <0-65535> <0-32767> <0-65535> <0-1>[LINE]",
- "Test\n"
- "Test PIM protocol\n"
- "Test PIM message reception\n"
- "Test PIM hello reception from neighbor\n"
- "Interface\n"
- "Neighbor address\n"
- "Neighbor holdtime\n"
- "Neighbor DR priority\n"
- "Neighbor generation ID\n"
- "Neighbor propagation delay (msec)\n"
- "Neighbor override interval (msec)\n"
- "Neighbor LAN prune delay T-bit\n"
- "Neighbor secondary addresses\n")
- {
- char buf[1000];
- char *pim_msg;
- struct ip *ip_hdr;
- size_t ip_hlen; /* ip header length in bytes */
- int ip_msg_len;
- int pim_tlv_size;
- int pim_msg_size;
- const char *neigh_str;
- struct in_addr neigh_addr;
- const char *ifname;
- struct interface *ifp;
- uint16_t neigh_holdtime;
- uint16_t neigh_propagation_delay;
- uint16_t neigh_override_interval;
- int neigh_can_disable_join_suppression;
- uint32_t neigh_dr_priority;
- uint32_t neigh_generation_id;
- int argi;
- int result;
- /* Find interface */
- ifname = argv[0];
- ifp = if_lookup_by_name(ifname);
- if (!ifp) {
- vty_out(vty, "No such interface name %s%s",
- ifname, VTY_NEWLINE);
- return CMD_WARNING;
- }
- /* Neighbor address */
- neigh_str = argv[1];
- result = inet_pton(AF_INET, neigh_str, &neigh_addr);
- if (result <= 0) {
- vty_out(vty, "Bad neighbor address %s: errno=%d: %s%s",
- neigh_str, errno, strerror(errno), VTY_NEWLINE);
- return CMD_WARNING;
- }
- neigh_holdtime = atoi(argv[2]);
- neigh_dr_priority = atoi(argv[3]);
- neigh_generation_id = atoi(argv[4]);
- neigh_propagation_delay = atoi(argv[5]);
- neigh_override_interval = atoi(argv[6]);
- neigh_can_disable_join_suppression = atoi(argv[7]);
- /*
- Tweak IP header
- */
- ip_hdr = (struct ip *) buf;
- ip_hdr->ip_p = PIM_IP_PROTO_PIM;
- ip_hlen = PIM_IP_HEADER_MIN_LEN; /* ip header length in bytes */
- ip_hdr->ip_hl = ip_hlen >> 2; /* ip header length in 4-byte words */
- ip_hdr->ip_src = neigh_addr;
- ip_hdr->ip_dst = qpim_all_pim_routers_addr;
- /*
- Build PIM hello message
- */
- pim_msg = buf + ip_hlen;
- /* Scan LINE addresses */
- for (argi = 8; argi < argc; ++argi) {
- const char *sec_str = argv[argi];
- struct in_addr sec_addr;
- result = inet_pton(AF_INET, sec_str, &sec_addr);
- if (result <= 0) {
- vty_out(vty, "Bad neighbor secondary address %s: errno=%d: %s%s",
- sec_str, errno, strerror(errno), VTY_NEWLINE);
- return CMD_WARNING;
- }
- vty_out(vty,
- "FIXME WRITEME consider neighbor secondary address %s%s",
- sec_str, VTY_NEWLINE);
- }
- pim_tlv_size = pim_hello_build_tlv(ifp->name,
- pim_msg + PIM_PIM_MIN_LEN,
- sizeof(buf) - ip_hlen - PIM_PIM_MIN_LEN,
- neigh_holdtime,
- neigh_dr_priority,
- neigh_generation_id,
- neigh_propagation_delay,
- neigh_override_interval,
- neigh_can_disable_join_suppression,
- 0 /* FIXME secondary address list */);
- if (pim_tlv_size < 0) {
- vty_out(vty, "pim_hello_build_tlv() returned failure: %d%s",
- pim_tlv_size, VTY_NEWLINE);
- return CMD_WARNING;
- }
- pim_msg_size = pim_tlv_size + PIM_PIM_MIN_LEN;
- pim_msg_build_header(pim_msg, pim_msg_size,
- PIM_MSG_TYPE_HELLO);
- /* "receive" message */
- ip_msg_len = ip_hlen + pim_msg_size;
- result = pim_pim_packet(ifp, buf, ip_msg_len);
- if (result) {
- vty_out(vty, "pim_pim_packet(len=%d) returned failure: %d%s",
- ip_msg_len, result, VTY_NEWLINE);
- return CMD_WARNING;
- }
- return CMD_SUCCESS;
- }
- DEFUN (test_pim_receive_assert,
- test_pim_receive_assert_cmd,
- "test pim receive assert INTERFACE A.B.C.D A.B.C.D A.B.C.D <0-65535> <0-65535> <0-1>",
- "Test\n"
- "Test PIM protocol\n"
- "Test PIM message reception\n"
- "Test reception of PIM assert\n"
- "Interface\n"
- "Neighbor address\n"
- "Assert multicast group address\n"
- "Assert unicast source address\n"
- "Assert metric preference\n"
- "Assert route metric\n"
- "Assert RPT bit flag\n")
- {
- char buf[1000];
- char *buf_pastend = buf + sizeof(buf);
- char *pim_msg;
- struct ip *ip_hdr;
- size_t ip_hlen; /* ip header length in bytes */
- int ip_msg_len;
- int pim_msg_size;
- const char *neigh_str;
- struct in_addr neigh_addr;
- const char *group_str;
- struct in_addr group_addr;
- const char *source_str;
- struct in_addr source_addr;
- const char *ifname;
- struct interface *ifp;
- uint32_t assert_metric_preference;
- uint32_t assert_route_metric;
- uint32_t assert_rpt_bit_flag;
- int remain;
- int result;
- /* Find interface */
- ifname = argv[0];
- ifp = if_lookup_by_name(ifname);
- if (!ifp) {
- vty_out(vty, "No such interface name %s%s",
- ifname, VTY_NEWLINE);
- return CMD_WARNING;
- }
- /* Neighbor address */
- neigh_str = argv[1];
- result = inet_pton(AF_INET, neigh_str, &neigh_addr);
- if (result <= 0) {
- vty_out(vty, "Bad neighbor address %s: errno=%d: %s%s",
- neigh_str, errno, strerror(errno), VTY_NEWLINE);
- return CMD_WARNING;
- }
- /* Group address */
- group_str = argv[2];
- result = inet_pton(AF_INET, group_str, &group_addr);
- if (result <= 0) {
- vty_out(vty, "Bad group address %s: errno=%d: %s%s",
- group_str, errno, strerror(errno), VTY_NEWLINE);
- return CMD_WARNING;
- }
- /* Source address */
- source_str = argv[3];
- result = inet_pton(AF_INET, source_str, &source_addr);
- if (result <= 0) {
- vty_out(vty, "Bad source address %s: errno=%d: %s%s",
- source_str, errno, strerror(errno), VTY_NEWLINE);
- return CMD_WARNING;
- }
- assert_metric_preference = atoi(argv[4]);
- assert_route_metric = atoi(argv[5]);
- assert_rpt_bit_flag = atoi(argv[6]);
- remain = buf_pastend - buf;
- if (remain < (int) sizeof(struct ip)) {
- vty_out(vty, "No room for ip header: buf_size=%d < ip_header_size=%d%s",
- remain, sizeof(struct ip), VTY_NEWLINE);
- return CMD_WARNING;
- }
- /*
- Tweak IP header
- */
- ip_hdr = (struct ip *) buf;
- ip_hdr->ip_p = PIM_IP_PROTO_PIM;
- ip_hlen = PIM_IP_HEADER_MIN_LEN; /* ip header length in bytes */
- ip_hdr->ip_hl = ip_hlen >> 2; /* ip header length in 4-byte words */
- ip_hdr->ip_src = neigh_addr;
- ip_hdr->ip_dst = qpim_all_pim_routers_addr;
- /*
- Build PIM assert message
- */
- pim_msg = buf + ip_hlen; /* skip ip header */
- pim_msg_size = pim_assert_build_msg(pim_msg, buf_pastend - pim_msg, ifp,
- group_addr, source_addr,
- assert_metric_preference,
- assert_route_metric,
- assert_rpt_bit_flag);
- if (pim_msg_size < 0) {
- vty_out(vty, "Failure building PIM assert message: size=%d%s",
- pim_msg_size, VTY_NEWLINE);
- return CMD_WARNING;
- }
- /* "receive" message */
- ip_msg_len = ip_hlen + pim_msg_size;
- result = pim_pim_packet(ifp, buf, ip_msg_len);
- if (result) {
- vty_out(vty, "pim_pim_packet(len=%d) returned failure: %d%s",
- ip_msg_len, result, VTY_NEWLINE);
- return CMD_WARNING;
- }
- return CMD_SUCCESS;
- }
- static int recv_joinprune(struct vty *vty,
- const char *argv[],
- int src_is_join)
- {
- char buf[1000];
- const char *buf_pastend = buf + sizeof(buf);
- char *pim_msg;
- char *pim_msg_curr;
- int pim_msg_size;
- struct ip *ip_hdr;
- size_t ip_hlen; /* ip header length in bytes */
- int ip_msg_len;
- uint16_t neigh_holdtime;
- const char *neigh_dst_str;
- struct in_addr neigh_dst_addr;
- const char *neigh_src_str;
- struct in_addr neigh_src_addr;
- const char *group_str;
- struct in_addr group_addr;
- const char *source_str;
- struct in_addr source_addr;
- const char *ifname;
- struct interface *ifp;
- int result;
- int remain;
- uint16_t num_joined;
- uint16_t num_pruned;
- /* Find interface */
- ifname = argv[0];
- ifp = if_lookup_by_name(ifname);
- if (!ifp) {
- vty_out(vty, "No such interface name %s%s",
- ifname, VTY_NEWLINE);
- return CMD_WARNING;
- }
- neigh_holdtime = atoi(argv[1]);
- /* Neighbor destination address */
- neigh_dst_str = argv[2];
- result = inet_pton(AF_INET, neigh_dst_str, &neigh_dst_addr);
- if (result <= 0) {
- vty_out(vty, "Bad neighbor destination address %s: errno=%d: %s%s",
- neigh_dst_str, errno, strerror(errno), VTY_NEWLINE);
- return CMD_WARNING;
- }
- /* Neighbor source address */
- neigh_src_str = argv[3];
- result = inet_pton(AF_INET, neigh_src_str, &neigh_src_addr);
- if (result <= 0) {
- vty_out(vty, "Bad neighbor source address %s: errno=%d: %s%s",
- neigh_src_str, errno, strerror(errno), VTY_NEWLINE);
- return CMD_WARNING;
- }
- /* Multicast group address */
- group_str = argv[4];
- result = inet_pton(AF_INET, group_str, &group_addr);
- if (result <= 0) {
- vty_out(vty, "Bad group address %s: errno=%d: %s%s",
- group_str, errno, strerror(errno), VTY_NEWLINE);
- return CMD_WARNING;
- }
- /* Multicast source address */
- source_str = argv[5];
- result = inet_pton(AF_INET, source_str, &source_addr);
- if (result <= 0) {
- vty_out(vty, "Bad source address %s: errno=%d: %s%s",
- source_str, errno, strerror(errno), VTY_NEWLINE);
- return CMD_WARNING;
- }
- /*
- Tweak IP header
- */
- ip_hdr = (struct ip *) buf;
- ip_hdr->ip_p = PIM_IP_PROTO_PIM;
- ip_hlen = PIM_IP_HEADER_MIN_LEN; /* ip header length in bytes */
- ip_hdr->ip_hl = ip_hlen >> 2; /* ip header length in 4-byte words */
- ip_hdr->ip_src = neigh_src_addr;
- ip_hdr->ip_dst = qpim_all_pim_routers_addr;
- /*
- Build PIM message
- */
- pim_msg = buf + ip_hlen;
- /* skip room for pim header */
- pim_msg_curr = pim_msg + PIM_MSG_HEADER_LEN;
- remain = buf_pastend - pim_msg_curr;
- pim_msg_curr = pim_msg_addr_encode_ipv4_ucast(pim_msg_curr,
- remain,
- neigh_dst_addr);
- if (!pim_msg_curr) {
- vty_out(vty, "Failure encoding destination address %s: space left=%d%s",
- neigh_dst_str, remain, VTY_NEWLINE);
- return CMD_WARNING;
- }
- remain = buf_pastend - pim_msg_curr;
- if (remain < 4) {
- vty_out(vty, "Group will not fit: space left=%d%s",
- remain, VTY_NEWLINE);
- return CMD_WARNING;
- }
- *pim_msg_curr = 0; /* reserved */
- ++pim_msg_curr;
- *pim_msg_curr = 1; /* number of groups */
- ++pim_msg_curr;
- *((uint16_t *) pim_msg_curr) = htons(neigh_holdtime);
- ++pim_msg_curr;
- ++pim_msg_curr;
- remain = buf_pastend - pim_msg_curr;
- pim_msg_curr = pim_msg_addr_encode_ipv4_group(pim_msg_curr,
- remain,
- group_addr);
- if (!pim_msg_curr) {
- vty_out(vty, "Failure encoding group address %s: space left=%d%s",
- group_str, remain, VTY_NEWLINE);
- return CMD_WARNING;
- }
- remain = buf_pastend - pim_msg_curr;
- if (remain < 4) {
- vty_out(vty, "Sources will not fit: space left=%d%s",
- remain, VTY_NEWLINE);
- return CMD_WARNING;
- }
- if (src_is_join) {
- num_joined = 1;
- num_pruned = 0;
- }
- else {
- num_joined = 0;
- num_pruned = 1;
- }
- /* number of joined sources */
- *((uint16_t *) pim_msg_curr) = htons(num_joined);
- ++pim_msg_curr;
- ++pim_msg_curr;
- /* number of pruned sources */
- *((uint16_t *) pim_msg_curr) = htons(num_pruned);
- ++pim_msg_curr;
- ++pim_msg_curr;
- remain = buf_pastend - pim_msg_curr;
- pim_msg_curr = pim_msg_addr_encode_ipv4_source(pim_msg_curr,
- remain,
- source_addr);
- if (!pim_msg_curr) {
- vty_out(vty, "Failure encoding source address %s: space left=%d%s",
- source_str, remain, VTY_NEWLINE);
- return CMD_WARNING;
- }
- /* Add PIM header */
- pim_msg_size = pim_msg_curr - pim_msg;
- pim_msg_build_header(pim_msg, pim_msg_size,
- PIM_MSG_TYPE_JOIN_PRUNE);
- /*
- "Receive" message
- */
- ip_msg_len = ip_hlen + pim_msg_size;
- result = pim_pim_packet(ifp, buf, ip_msg_len);
- if (result) {
- vty_out(vty, "pim_pim_packet(len=%d) returned failure: %d%s",
- ip_msg_len, result, VTY_NEWLINE);
- return CMD_WARNING;
- }
- return CMD_SUCCESS;
- }
- DEFUN (test_pim_receive_join,
- test_pim_receive_join_cmd,
- "test pim receive join INTERFACE <0-65535> A.B.C.D A.B.C.D A.B.C.D A.B.C.D",
- "Test\n"
- "Test PIM protocol\n"
- "Test PIM message reception\n"
- "Test PIM join reception from neighbor\n"
- "Interface\n"
- "Neighbor holdtime\n"
- "Upstream neighbor unicast destination address\n"
- "Downstream neighbor unicast source address\n"
- "Multicast group address\n"
- "Unicast source address\n")
- {
- return recv_joinprune(vty, argv, 1 /* src_is_join=true */);
- }
- DEFUN (test_pim_receive_prune,
- test_pim_receive_prune_cmd,
- "test pim receive prune INTERFACE <0-65535> A.B.C.D A.B.C.D A.B.C.D A.B.C.D",
- "Test\n"
- "Test PIM protocol\n"
- "Test PIM message reception\n"
- "Test PIM prune reception from neighbor\n"
- "Interface\n"
- "Neighbor holdtime\n"
- "Upstream neighbor unicast destination address\n"
- "Downstream neighbor unicast source address\n"
- "Multicast group address\n"
- "Unicast source address\n")
- {
- return recv_joinprune(vty, argv, 0 /* src_is_join=false */);
- }
- DEFUN (test_pim_receive_upcall,
- test_pim_receive_upcall_cmd,
- "test pim receive upcall (nocache|wrongvif|wholepkt) <0-65535> A.B.C.D A.B.C.D",
- "Test\n"
- "Test PIM protocol\n"
- "Test PIM message reception\n"
- "Test reception of kernel upcall\n"
- "NOCACHE kernel upcall\n"
- "WRONGVIF kernel upcall\n"
- "WHOLEPKT kernel upcall\n"
- "Input interface vif index\n"
- "Multicast group address\n"
- "Multicast source address\n")
- {
- struct igmpmsg msg;
- const char *upcall_type;
- const char *group_str;
- const char *source_str;
- int result;
- upcall_type = argv[0];
- if (upcall_type[0] == 'n')
- msg.im_msgtype = IGMPMSG_NOCACHE;
- else if (upcall_type[1] == 'r')
- msg.im_msgtype = IGMPMSG_WRONGVIF;
- else if (upcall_type[1] == 'h')
- msg.im_msgtype = IGMPMSG_WHOLEPKT;
- else {
- vty_out(vty, "Unknown kernel upcall type: %s%s",
- upcall_type, VTY_NEWLINE);
- return CMD_WARNING;
- }
- msg.im_vif = atoi(argv[1]);
- /* Group address */
- group_str = argv[2];
- result = inet_pton(AF_INET, group_str, &msg.im_dst);
- if (result <= 0) {
- vty_out(vty, "Bad group address %s: errno=%d: %s%s",
- group_str, errno, strerror(errno), VTY_NEWLINE);
- return CMD_WARNING;
- }
- /* Source address */
- source_str = argv[3];
- result = inet_pton(AF_INET, source_str, &msg.im_src);
- if (result <= 0) {
- vty_out(vty, "Bad source address %s: errno=%d: %s%s",
- source_str, errno, strerror(errno), VTY_NEWLINE);
- return CMD_WARNING;
- }
- msg.im_mbz = 0; /* Must be zero */
- result = pim_mroute_msg(-1, (char *) &msg, sizeof(msg));
- if (result) {
- vty_out(vty, "pim_mroute_msg(len=%d) returned failure: %d%s",
- sizeof(msg), result, VTY_NEWLINE);
- return CMD_WARNING;
- }
- return CMD_SUCCESS;
- }
- void pim_cmd_init()
- {
- install_node (&pim_global_node, pim_global_config_write); /* PIM_NODE */
- install_node (&interface_node, pim_interface_config_write); /* INTERFACE_NODE */
- install_element (CONFIG_NODE, &ip_multicast_routing_cmd);
- install_element (CONFIG_NODE, &no_ip_multicast_routing_cmd);
- #if 0
- install_element (CONFIG_NODE, &interface_cmd); /* from if.h */
- #else
- install_element (CONFIG_NODE, &pim_interface_cmd);
- #endif
- install_element (CONFIG_NODE, &no_interface_cmd); /* from if.h */
- install_default (INTERFACE_NODE);
- install_element (INTERFACE_NODE, &interface_ip_igmp_cmd);
- install_element (INTERFACE_NODE, &interface_no_ip_igmp_cmd);
- install_element (INTERFACE_NODE, &interface_ip_igmp_join_cmd);
- install_element (INTERFACE_NODE, &interface_no_ip_igmp_join_cmd);
- install_element (INTERFACE_NODE, &interface_ip_igmp_query_interval_cmd);
- install_element (INTERFACE_NODE, &interface_no_ip_igmp_query_interval_cmd);
- install_element (INTERFACE_NODE, &interface_ip_igmp_query_max_response_time_cmd);
- install_element (INTERFACE_NODE, &interface_no_ip_igmp_query_max_response_time_cmd);
- install_element (INTERFACE_NODE, &interface_ip_igmp_query_max_response_time_dsec_cmd);
- install_element (INTERFACE_NODE, &interface_no_ip_igmp_query_max_response_time_dsec_cmd);
- install_element (INTERFACE_NODE, &interface_ip_pim_ssm_cmd);
- install_element (INTERFACE_NODE, &interface_no_ip_pim_ssm_cmd);
- install_element (VIEW_NODE, &show_ip_igmp_interface_cmd);
- install_element (VIEW_NODE, &show_ip_igmp_parameters_cmd);
- install_element (VIEW_NODE, &show_ip_igmp_groups_cmd);
- install_element (VIEW_NODE, &show_ip_igmp_groups_retransmissions_cmd);
- install_element (VIEW_NODE, &show_ip_igmp_sources_cmd);
- install_element (VIEW_NODE, &show_ip_igmp_sources_retransmissions_cmd);
- install_element (VIEW_NODE, &show_ip_igmp_querier_cmd);
- install_element (VIEW_NODE, &show_ip_pim_assert_cmd);
- install_element (VIEW_NODE, &show_ip_pim_assert_internal_cmd);
- install_element (VIEW_NODE, &show_ip_pim_assert_metric_cmd);
- install_element (VIEW_NODE, &show_ip_pim_assert_winner_metric_cmd);
- install_element (VIEW_NODE, &show_ip_pim_dr_cmd);
- install_element (VIEW_NODE, &show_ip_pim_hello_cmd);
- install_element (VIEW_NODE, &show_ip_pim_interface_cmd);
- install_element (VIEW_NODE, &show_ip_pim_join_cmd);
- install_element (VIEW_NODE, &show_ip_pim_jp_override_interval_cmd);
- install_element (VIEW_NODE, &show_ip_pim_lan_prune_delay_cmd);
- install_element (VIEW_NODE, &show_ip_pim_local_membership_cmd);
- install_element (VIEW_NODE, &show_ip_pim_neighbor_cmd);
- install_element (VIEW_NODE, &show_ip_pim_rpf_cmd);
- install_element (VIEW_NODE, &show_ip_pim_secondary_cmd);
- install_element (VIEW_NODE, &show_ip_pim_upstream_cmd);
- install_element (VIEW_NODE, &show_ip_pim_upstream_join_desired_cmd);
- install_element (VIEW_NODE, &show_ip_pim_upstream_rpf_cmd);
- install_element (VIEW_NODE, &show_ip_multicast_cmd);
- install_element (VIEW_NODE, &show_ip_mroute_cmd);
- install_element (VIEW_NODE, &show_ip_mroute_count_cmd);
- install_element (VIEW_NODE, &show_ip_route_cmd);
- install_element (VIEW_NODE, &show_debugging_cmd);
- install_element (ENABLE_NODE, &clear_ip_interfaces_cmd);
- install_element (ENABLE_NODE, &clear_ip_igmp_interfaces_cmd);
- install_element (ENABLE_NODE, &clear_ip_pim_interfaces_cmd);
- install_element (ENABLE_NODE, &show_ip_igmp_interface_cmd);
- install_element (ENABLE_NODE, &show_ip_igmp_parameters_cmd);
- install_element (ENABLE_NODE, &show_ip_igmp_groups_cmd);
- install_element (ENABLE_NODE, &show_ip_igmp_groups_retransmissions_cmd);
- install_element (ENABLE_NODE, &show_ip_igmp_sources_cmd);
- install_element (ENABLE_NODE, &show_ip_igmp_sources_retransmissions_cmd);
- install_element (ENABLE_NODE, &show_ip_igmp_querier_cmd);
- install_element (ENABLE_NODE, &show_ip_pim_address_cmd);
- install_element (ENABLE_NODE, &show_ip_pim_assert_cmd);
- install_element (ENABLE_NODE, &show_ip_pim_assert_internal_cmd);
- install_element (ENABLE_NODE, &show_ip_pim_assert_metric_cmd);
- install_element (ENABLE_NODE, &show_ip_pim_assert_winner_metric_cmd);
- install_element (ENABLE_NODE, &show_ip_pim_dr_cmd);
- install_element (ENABLE_NODE, &show_ip_pim_hello_cmd);
- install_element (ENABLE_NODE, &show_ip_pim_interface_cmd);
- install_element (ENABLE_NODE, &show_ip_pim_join_cmd);
- install_element (ENABLE_NODE, &show_ip_pim_jp_override_interval_cmd);
- install_element (ENABLE_NODE, &show_ip_pim_lan_prune_delay_cmd);
- install_element (ENABLE_NODE, &show_ip_pim_local_membership_cmd);
- install_element (ENABLE_NODE, &show_ip_pim_neighbor_cmd);
- install_element (ENABLE_NODE, &show_ip_pim_rpf_cmd);
- install_element (ENABLE_NODE, &show_ip_pim_secondary_cmd);
- install_element (ENABLE_NODE, &show_ip_pim_upstream_cmd);
- install_element (ENABLE_NODE, &show_ip_pim_upstream_join_desired_cmd);
- install_element (ENABLE_NODE, &show_ip_pim_upstream_rpf_cmd);
- install_element (ENABLE_NODE, &show_ip_multicast_cmd);
- install_element (ENABLE_NODE, &show_ip_mroute_cmd);
- install_element (ENABLE_NODE, &show_ip_mroute_count_cmd);
- install_element (ENABLE_NODE, &show_ip_route_cmd);
- install_element (ENABLE_NODE, &show_debugging_cmd);
- install_element (ENABLE_NODE, &test_igmp_receive_report_cmd);
- install_element (ENABLE_NODE, &test_pim_receive_assert_cmd);
- install_element (ENABLE_NODE, &test_pim_receive_hello_cmd);
- install_element (ENABLE_NODE, &test_pim_receive_join_cmd);
- install_element (ENABLE_NODE, &test_pim_receive_prune_cmd);
- install_element (ENABLE_NODE, &test_pim_receive_upcall_cmd);
- install_element (ENABLE_NODE, &debug_igmp_cmd);
- install_element (ENABLE_NODE, &no_debug_igmp_cmd);
- install_element (ENABLE_NODE, &undebug_igmp_cmd);
- install_element (ENABLE_NODE, &debug_igmp_events_cmd);
- install_element (ENABLE_NODE, &no_debug_igmp_events_cmd);
- install_element (ENABLE_NODE, &undebug_igmp_events_cmd);
- install_element (ENABLE_NODE, &debug_igmp_packets_cmd);
- install_element (ENABLE_NODE, &no_debug_igmp_packets_cmd);
- install_element (ENABLE_NODE, &undebug_igmp_packets_cmd);
- install_element (ENABLE_NODE, &debug_igmp_trace_cmd);
- install_element (ENABLE_NODE, &no_debug_igmp_trace_cmd);
- install_element (ENABLE_NODE, &undebug_igmp_trace_cmd);
- install_element (ENABLE_NODE, &debug_pim_cmd);
- install_element (ENABLE_NODE, &no_debug_pim_cmd);
- install_element (ENABLE_NODE, &undebug_pim_cmd);
- install_element (ENABLE_NODE, &debug_pim_events_cmd);
- install_element (ENABLE_NODE, &no_debug_pim_events_cmd);
- install_element (ENABLE_NODE, &undebug_pim_events_cmd);
- install_element (ENABLE_NODE, &debug_pim_packets_cmd);
- install_element (ENABLE_NODE, &no_debug_pim_packets_cmd);
- install_element (ENABLE_NODE, &undebug_pim_packets_cmd);
- install_element (ENABLE_NODE, &debug_pim_trace_cmd);
- install_element (ENABLE_NODE, &no_debug_pim_trace_cmd);
- install_element (ENABLE_NODE, &undebug_pim_trace_cmd);
- install_element (ENABLE_NODE, &debug_pim_zebra_cmd);
- install_element (ENABLE_NODE, &no_debug_pim_zebra_cmd);
- install_element (ENABLE_NODE, &undebug_pim_zebra_cmd);
- install_element (CONFIG_NODE, &debug_igmp_cmd);
- install_element (CONFIG_NODE, &no_debug_igmp_cmd);
- install_element (CONFIG_NODE, &undebug_igmp_cmd);
- install_element (CONFIG_NODE, &debug_igmp_events_cmd);
- install_element (CONFIG_NODE, &no_debug_igmp_events_cmd);
- install_element (CONFIG_NODE, &undebug_igmp_events_cmd);
- install_element (CONFIG_NODE, &debug_igmp_packets_cmd);
- install_element (CONFIG_NODE, &no_debug_igmp_packets_cmd);
- install_element (CONFIG_NODE, &undebug_igmp_packets_cmd);
- install_element (CONFIG_NODE, &debug_igmp_trace_cmd);
- install_element (CONFIG_NODE, &no_debug_igmp_trace_cmd);
- install_element (CONFIG_NODE, &undebug_igmp_trace_cmd);
- install_element (CONFIG_NODE, &debug_pim_cmd);
- install_element (CONFIG_NODE, &no_debug_pim_cmd);
- install_element (CONFIG_NODE, &undebug_pim_cmd);
- install_element (CONFIG_NODE, &debug_pim_events_cmd);
- install_element (CONFIG_NODE, &no_debug_pim_events_cmd);
- install_element (CONFIG_NODE, &undebug_pim_events_cmd);
- install_element (CONFIG_NODE, &debug_pim_packets_cmd);
- install_element (CONFIG_NODE, &no_debug_pim_packets_cmd);
- install_element (CONFIG_NODE, &undebug_pim_packets_cmd);
- install_element (CONFIG_NODE, &debug_pim_trace_cmd);
- install_element (CONFIG_NODE, &no_debug_pim_trace_cmd);
- install_element (CONFIG_NODE, &undebug_pim_trace_cmd);
- install_element (CONFIG_NODE, &debug_pim_zebra_cmd);
- install_element (CONFIG_NODE, &no_debug_pim_zebra_cmd);
- install_element (CONFIG_NODE, &undebug_pim_zebra_cmd);
- }
|