back to topotato report
topotato coverage report
Current view: top level - lib - mlag.c (source / functions) Hit Total Coverage
Test: test_bgp_aggregate_address_route_map.py::BGPAggregateAddressRouteMap Lines: 0 96 0.0 %
Date: 2023-02-24 18:36:44 Functions: 0 8 0.0 %

          Line data    Source code
       1             : /* mlag generic code.
       2             :  * Copyright (C) 2018 Cumulus Networks, Inc.
       3             :  *                    Donald Sharp
       4             :  *
       5             :  * This file is part of FRR.
       6             :  *
       7             :  * FRR is free software; you can redistribute it and/or modify it
       8             :  * under the terms of the GNU General Public License as published by the
       9             :  * Free Software Foundation; either version 2, or (at your option) any
      10             :  * later version.
      11             :  *
      12             :  * FRR is distributed in the hope that it will be useful, but
      13             :  * WITHOUT ANY WARRANTY; without even the implied warranty of
      14             :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      15             :  * General Public License for more details.
      16             :  *
      17             :  * You should have received a copy of the GNU General Public License
      18             :  * along with FRR; see the file COPYING.  If not, write to the Free
      19             :  * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
      20             :  * 02111-1307, USA.
      21             :  */
      22             : #include <zebra.h>
      23             : 
      24             : #include <mlag.h>
      25             : 
      26           0 : char *mlag_role2str(enum mlag_role role, char *buf, size_t size)
      27             : {
      28           0 :         switch (role) {
      29           0 :         case MLAG_ROLE_NONE:
      30           0 :                 snprintf(buf, size, "NONE");
      31           0 :                 break;
      32           0 :         case MLAG_ROLE_PRIMARY:
      33           0 :                 snprintf(buf, size, "PRIMARY");
      34           0 :                 break;
      35           0 :         case MLAG_ROLE_SECONDARY:
      36           0 :                 snprintf(buf, size, "SECONDARY");
      37           0 :                 break;
      38             :         }
      39             : 
      40           0 :         return buf;
      41             : }
      42             : 
      43           0 : char *mlag_lib_msgid_to_str(enum mlag_msg_type msg_type, char *buf, size_t size)
      44             : {
      45           0 :         switch (msg_type) {
      46           0 :         case MLAG_REGISTER:
      47           0 :                 snprintf(buf, size, "Register");
      48           0 :                 break;
      49           0 :         case MLAG_DEREGISTER:
      50           0 :                 snprintf(buf, size, "De-Register");
      51           0 :                 break;
      52           0 :         case MLAG_MROUTE_ADD:
      53           0 :                 snprintf(buf, size, "Mroute add");
      54           0 :                 break;
      55           0 :         case MLAG_MROUTE_DEL:
      56           0 :                 snprintf(buf, size, "Mroute del");
      57           0 :                 break;
      58           0 :         case MLAG_DUMP:
      59           0 :                 snprintf(buf, size, "Mlag Replay");
      60           0 :                 break;
      61           0 :         case MLAG_MROUTE_ADD_BULK:
      62           0 :                 snprintf(buf, size, "Mroute Add Batch");
      63           0 :                 break;
      64           0 :         case MLAG_MROUTE_DEL_BULK:
      65           0 :                 snprintf(buf, size, "Mroute Del Batch");
      66           0 :                 break;
      67           0 :         case MLAG_STATUS_UPDATE:
      68           0 :                 snprintf(buf, size, "Mlag Status");
      69           0 :                 break;
      70           0 :         case MLAG_VXLAN_UPDATE:
      71           0 :                 snprintf(buf, size, "Mlag vxlan update");
      72           0 :                 break;
      73           0 :         case MLAG_PEER_FRR_STATUS:
      74           0 :                 snprintf(buf, size, "Mlag Peer FRR Status");
      75           0 :                 break;
      76           0 :         case MLAG_PIM_CFG_DUMP:
      77           0 :                 snprintf(buf, size, "Mlag Pim Configuration Dump");
      78           0 :                 break;
      79           0 :         case MLAG_MSG_NONE:
      80           0 :                 snprintf(buf, size, "Unknown %d", msg_type);
      81           0 :                 break;
      82             :         }
      83           0 :         return buf;
      84             : }
      85             : 
      86             : 
      87           0 : int mlag_lib_decode_mlag_hdr(struct stream *s, struct mlag_msg *msg,
      88             :                              size_t *length)
      89             : {
      90             : #define LIB_MLAG_HDR_LENGTH 8
      91           0 :         if (s == NULL || msg == NULL)
      92             :                 return -1;
      93             : 
      94           0 :         *length = stream_get_endp(s);
      95             : 
      96           0 :         if (*length < LIB_MLAG_HDR_LENGTH)
      97             :                 return -1;
      98             : 
      99           0 :         *length -= LIB_MLAG_HDR_LENGTH;
     100             : 
     101           0 :         STREAM_GETL(s, msg->msg_type);
     102           0 :         STREAM_GETW(s, msg->data_len);
     103           0 :         STREAM_GETW(s, msg->msg_cnt);
     104             : 
     105           0 :         return 0;
     106             : stream_failure:
     107             :         return -1;
     108             : }
     109             : 
     110             : #define MLAG_MROUTE_ADD_LENGTH                                                 \
     111             :         (VRF_NAMSIZ + INTERFACE_NAMSIZ + 4 + 4 + 4 + 4 + 1 + 1 + 4)
     112             : 
     113           0 : int mlag_lib_decode_mroute_add(struct stream *s, struct mlag_mroute_add *msg,
     114             :                                size_t *length)
     115             : {
     116           0 :         if (s == NULL || msg == NULL || *length < MLAG_MROUTE_ADD_LENGTH)
     117             :                 return -1;
     118             : 
     119           0 :         STREAM_GET(msg->vrf_name, s, VRF_NAMSIZ);
     120           0 :         STREAM_GETL(s, msg->source_ip);
     121           0 :         STREAM_GETL(s, msg->group_ip);
     122           0 :         STREAM_GETL(s, msg->cost_to_rp);
     123           0 :         STREAM_GETL(s, msg->owner_id);
     124           0 :         STREAM_GETC(s, msg->am_i_dr);
     125           0 :         STREAM_GETC(s, msg->am_i_dual_active);
     126           0 :         STREAM_GETL(s, msg->vrf_id);
     127           0 :         STREAM_GET(msg->intf_name, s, INTERFACE_NAMSIZ);
     128             : 
     129             :         return 0;
     130             : stream_failure:
     131             :         return -1;
     132             : }
     133             : 
     134             : #define MLAG_MROUTE_DEL_LENGTH (VRF_NAMSIZ + INTERFACE_NAMSIZ + 4 + 4 + 4 + 4)
     135             : 
     136           0 : int mlag_lib_decode_mroute_del(struct stream *s, struct mlag_mroute_del *msg,
     137             :                                size_t *length)
     138             : {
     139           0 :         if (s == NULL || msg == NULL || *length < MLAG_MROUTE_DEL_LENGTH)
     140             :                 return -1;
     141             : 
     142           0 :         STREAM_GET(msg->vrf_name, s, VRF_NAMSIZ);
     143           0 :         STREAM_GETL(s, msg->source_ip);
     144           0 :         STREAM_GETL(s, msg->group_ip);
     145           0 :         STREAM_GETL(s, msg->owner_id);
     146           0 :         STREAM_GETL(s, msg->vrf_id);
     147           0 :         STREAM_GET(msg->intf_name, s, INTERFACE_NAMSIZ);
     148             : 
     149             :         return 0;
     150             : stream_failure:
     151             :         return -1;
     152             : }
     153             : 
     154           0 : int mlag_lib_decode_mlag_status(struct stream *s, struct mlag_status *msg)
     155             : {
     156           0 :         if (s == NULL || msg == NULL)
     157             :                 return -1;
     158             : 
     159           0 :         STREAM_GET(msg->peerlink_rif, s, INTERFACE_NAMSIZ);
     160           0 :         STREAM_GETL(s, msg->my_role);
     161           0 :         STREAM_GETL(s, msg->peer_state);
     162           0 :         return 0;
     163             : stream_failure:
     164             :         return -1;
     165             : }
     166             : 
     167           0 : int mlag_lib_decode_vxlan_update(struct stream *s, struct mlag_vxlan *msg)
     168             : {
     169           0 :         if (s == NULL || msg == NULL)
     170             :                 return -1;
     171             : 
     172           0 :         STREAM_GETL(s, msg->anycast_ip);
     173           0 :         STREAM_GETL(s, msg->local_ip);
     174           0 :         return 0;
     175             : 
     176             : stream_failure:
     177             :         return -1;
     178             : }
     179             : 
     180           0 : int mlag_lib_decode_frr_status(struct stream *s, struct mlag_frr_status *msg)
     181             : {
     182           0 :         if (s == NULL || msg == NULL)
     183             :                 return -1;
     184             : 
     185           0 :         STREAM_GETL(s, msg->frr_state);
     186           0 :         return 0;
     187           0 : stream_failure:
     188           0 :         return -1;
     189             : }

Generated by: LCOV version v1.16-topotato