LCOV - code coverage report
Current view: top level - ksync - ksync_netlink.cc (source / functions) Hit Total Coverage
Test: OpenSDN C/C++ coverage (all TARGET_SET jobs) Lines: 61 69 88.4 %
Date: 2026-06-11 01:56:02 Functions: 6 6 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :  * Copyright (c) 2013 Juniper Networks, Inc. All rights reserved.
       3             :  */
       4             : 
       5             : #include <sys/types.h>
       6             : #include <sys/socket.h>
       7             : #if defined(__linux__)
       8             : #include <linux/netlink.h>
       9             : #include <linux/rtnetlink.h>
      10             : #include <linux/sockios.h>
      11             : #endif
      12             : 
      13             : #include <boost/bind/bind.hpp>
      14             : 
      15             : #include <base/logging.h>
      16             : #include <db/db.h>
      17             : #include <db/db_entry.h>
      18             : #include <db/db_table.h>
      19             : #include <db/db_table_partition.h>
      20             : 
      21             : #include <sandesh/sandesh_trace.h>
      22             : 
      23             : #include "ksync_index.h"
      24             : #include "ksync_entry.h"
      25             : #include "ksync_object.h"
      26             : #include "ksync_sock.h"
      27             : #include "ksync_types.h"
      28             : #include "ksync_netlink.h"
      29             : 
      30             : using namespace boost::placeholders;
      31             : 
      32             : ///////////////////////////////////////////////////////////////////////////////
      33             : // KSyncNetlinkEntry routines
      34             : ///////////////////////////////////////////////////////////////////////////////
      35          44 : bool KSyncNetlinkEntry::Add() {
      36          44 :     Sync();
      37          44 :     int len = MsgLen();
      38          44 :     char *msg = (char *)malloc(len);
      39          44 :     int  msg_len = AddMsg(msg, len);
      40          44 :     assert(msg_len <= len);
      41          44 :     if (msg_len == 0) {
      42           0 :         free(msg);
      43           0 :         return true;
      44             :     }
      45          44 :     KSyncSock   *sock = KSyncSock::Get(0);
      46          44 :     sock->SendAsync(this, msg_len, msg, KSyncEntry::ADD_ACK);
      47          44 :     return false;
      48             : }
      49             : 
      50          78 : bool KSyncNetlinkEntry::Change() {
      51          78 :     if (Sync() == false) {
      52          22 :         return true;
      53             :     }
      54             : 
      55          56 :     int len = MsgLen();
      56          56 :     char *msg = (char *)malloc(len);
      57          56 :     int  msg_len = ChangeMsg(msg, len);
      58          56 :     assert(msg_len <= len);
      59          56 :     if (msg_len == 0) {
      60           0 :         free(msg);
      61           0 :         return true;
      62             :     }
      63          56 :     KSyncSock   *sock = KSyncSock::Get(0);
      64          56 :     sock->SendAsync(this, msg_len, msg, KSyncEntry::CHANGE_ACK);
      65          56 :     return false;
      66             : }
      67             : 
      68          44 : bool KSyncNetlinkEntry::Delete() {
      69          44 :     int len = MsgLen();
      70          44 :     char *msg = (char *)malloc(len);
      71          44 :     int  msg_len = DeleteMsg(msg, len);
      72          44 :     assert(msg_len <= len);
      73          44 :     if (msg_len == 0) {
      74           0 :         free(msg);
      75           0 :         return true;
      76             :     }
      77          44 :     KSyncSock   *sock = KSyncSock::Get(0);
      78          44 :     sock->SendAsync(this, msg_len, msg, KSyncEntry::DEL_ACK);
      79          44 :     return false;
      80             : }
      81             : 
      82             : ///////////////////////////////////////////////////////////////////////////////
      83             : // KSyncNetlinkDBEntry routines
      84             : ///////////////////////////////////////////////////////////////////////////////
      85         384 : bool KSyncNetlinkDBEntry::Add() {
      86         384 :     int len = MsgLen();
      87         384 :     char *msg = (char *)malloc(len);
      88         384 :     int  msg_len = AddMsg(msg, len);
      89         384 :     assert(msg_len <= len);
      90         384 :     if (msg_len == 0) {
      91           2 :         free(msg);
      92           2 :         return true;
      93             :     }
      94         382 :     KSyncSock   *sock = KSyncSock::Get(0);
      95         382 :     sock->SendAsync(this, msg_len, msg, KSyncEntry::ADD_ACK);
      96         382 :     return false;
      97             : }
      98             : 
      99         112 : bool KSyncNetlinkDBEntry::Change() {
     100         112 :     int len = MsgLen();
     101         112 :     char *msg = (char *)malloc(len);
     102         112 :     int  msg_len = ChangeMsg(msg, len);
     103         112 :     assert(msg_len <= len);
     104         112 :     if (msg_len == 0) {
     105           2 :         free(msg);
     106           2 :         return true;
     107             :     }
     108         110 :     KSyncSock   *sock = KSyncSock::Get(0);
     109         110 :     sock->SendAsync(this, msg_len, msg, KSyncEntry::CHANGE_ACK);
     110         110 :     return false;
     111             : }
     112             : 
     113         384 : bool KSyncNetlinkDBEntry::Delete() {
     114         384 :     int len = MsgLen();
     115         384 :     char *msg = (char *)malloc(len);
     116         384 :     int  msg_len = DeleteMsg(msg, len);
     117         384 :     assert(msg_len <= len);
     118         384 :     if (msg_len == 0) {
     119           0 :         free(msg);
     120           0 :         return true;
     121             :     }
     122         384 :     KSyncSock   *sock = KSyncSock::Get(0);
     123         384 :     sock->SendAsync(this, msg_len, msg, KSyncEntry::DEL_ACK);
     124         384 :     return false;
     125             : }

Generated by: LCOV version 1.14