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

Generated by: LCOV version 1.14