X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=zebra%2Fzebra_mroute.c;h=881b681c2f6d837ae69ea62219701fc0dd90ad2c;hb=12906cb1c84b4de54874365d4a02a040ed9632d1;hp=ef0f2d8924ab4c4750dac8ce7a8ba4358ca949e5;hpb=adf1bb9f0cad57686ea5c112b9024389b95edf8e;p=mirror_frr.git diff --git a/zebra/zebra_mroute.c b/zebra/zebra_mroute.c index ef0f2d892..881b681c2 100644 --- a/zebra/zebra_mroute.c +++ b/zebra/zebra_mroute.c @@ -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 @@ -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,8 +66,19 @@ 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, (uint32_t)suc);