]> git.proxmox.com Git - mirror_frr.git/blobdiff - zebra/zebra_mroute.c
Merge pull request #12798 from donaldsharp/rib_match_multicast
[mirror_frr.git] / zebra / zebra_mroute.c
index 3af805558dd8c1474c2afa18061c9f58466cc282..881b681c2f6d837ae69ea62219701fc0dd90ad2c 100644 (file)
@@ -1,22 +1,9 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
 /* zebra_mroute code
  * Copyright (C) 2016 Cumulus Networks, Inc.
  * Donald Sharp
  *
  * This file is part of Quagga
- *
- * Quagga 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, or (at your option) any
- * later version.
- *
- * Quagga 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
  */
 
 #include <zebra.h>
@@ -39,20 +26,37 @@ void zebra_ipmr_route_stats(ZAPI_HANDLER_ARGS)
        int suc = -1;
 
        memset(&mroute, 0, sizeof(mroute));
-       STREAM_GET(&mroute.sg.src, msg, 4);
-       STREAM_GET(&mroute.sg.grp, msg, 4);
-       STREAM_GETL(msg, mroute.ifindex);
+       STREAM_GETL(msg, mroute.family);
 
-       if (IS_ZEBRA_DEBUG_KERNEL) {
-               char sbuf[40];
-               char gbuf[40];
+       switch (mroute.family) {
+       case AF_INET:
+               SET_IPADDR_V4(&mroute.src);
+               SET_IPADDR_V4(&mroute.grp);
+               STREAM_GET(&mroute.src.ipaddr_v4, msg,
+                          sizeof(mroute.src.ipaddr_v4));
+               STREAM_GET(&mroute.grp.ipaddr_v4, msg,
+                          sizeof(mroute.grp.ipaddr_v4));
+               break;
+       case AF_INET6:
+               SET_IPADDR_V6(&mroute.src);
+               SET_IPADDR_V6(&mroute.grp);
+               STREAM_GET(&mroute.src.ipaddr_v6, msg,
+                          sizeof(mroute.src.ipaddr_v6));
+               STREAM_GET(&mroute.grp.ipaddr_v6, msg,
+                          sizeof(mroute.grp.ipaddr_v6));
+               break;
+       default:
+               zlog_warn("%s: Invalid address family received while parsing",
+                         __func__);
+               return;
+       }
 
-               inet_ntop(AF_INET, &mroute.sg.src, sbuf, sizeof(sbuf));
-               inet_ntop(AF_INET, &mroute.sg.grp, gbuf, sizeof(gbuf));
+       STREAM_GETL(msg, mroute.ifindex);
 
-               zlog_debug("Asking for (%s,%s)[%s(%u)] mroute information",
-                          sbuf, gbuf, zvrf->vrf->name, zvrf->vrf->vrf_id);
-       }
+       if (IS_ZEBRA_DEBUG_KERNEL)
+               zlog_debug("Asking for (%pIA,%pIA)[%s(%u)] mroute information",
+                          &mroute.src, &mroute.grp, zvrf->vrf->name,
+                          zvrf->vrf->vrf_id);
 
        suc = kernel_get_ipmr_sg_stats(zvrf, &mroute);
 
@@ -62,10 +66,21 @@ stream_failure:
        stream_reset(s);
 
        zclient_create_header(s, ZEBRA_IPMR_ROUTE_STATS, zvrf_id(zvrf));
-       stream_put_in_addr(s, &mroute.sg.src);
-       stream_put_in_addr(s, &mroute.sg.grp);
+
+       if (mroute.family == AF_INET) {
+               stream_write(s, &mroute.src.ipaddr_v4,
+                            sizeof(mroute.src.ipaddr_v4));
+               stream_write(s, &mroute.grp.ipaddr_v4,
+                            sizeof(mroute.grp.ipaddr_v4));
+       } else {
+               stream_write(s, &mroute.src.ipaddr_v6,
+                            sizeof(mroute.src.ipaddr_v6));
+               stream_write(s, &mroute.grp.ipaddr_v6,
+                            sizeof(mroute.grp.ipaddr_v6));
+       }
+
        stream_put(s, &mroute.lastused, sizeof(mroute.lastused));
-       stream_putl(s, suc);
+       stream_putl(s, (uint32_t)suc);
 
        stream_putw_at(s, 0, stream_get_endp(s));
        zserv_send_message(client, s);