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-08-17 02:09:53 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         147 : bool KSyncNetlinkEntry::Add() {
      36         147 :     Sync();
      37         147 :     int len = MsgLen();
      38         147 :     char *msg = (char *)malloc(len);
      39         147 :     int  msg_len = AddMsg(msg, len);
      40         147 :     assert(msg_len <= len);
      41         147 :     if (msg_len == 0) {
      42           0 :         free(msg);
      43           0 :         return true;
      44             :     }
      45         147 :     KSyncSock   *sock = KSyncSock::Get(0);
      46         147 :     sock->SendAsync(this, msg_len, msg, KSyncEntry::ADD_ACK);
      47         147 :     return false;
      48             : }
      49             : 
      50         141 : bool KSyncNetlinkEntry::Change() {
      51         141 :     if (Sync() == false) {
      52          74 :         return true;
      53             :     }
      54             : 
      55          67 :     int len = MsgLen();
      56          67 :     char *msg = (char *)malloc(len);
      57          67 :     int  msg_len = ChangeMsg(msg, len);
      58          67 :     assert(msg_len <= len);
      59          67 :     if (msg_len == 0) {
      60           0 :         free(msg);
      61           0 :         return true;
      62             :     }
      63          67 :     KSyncSock   *sock = KSyncSock::Get(0);
      64          67 :     sock->SendAsync(this, msg_len, msg, KSyncEntry::CHANGE_ACK);
      65          67 :     return false;
      66             : }
      67             : 
      68         147 : bool KSyncNetlinkEntry::Delete() {
      69         147 :     int len = MsgLen();
      70         147 :     char *msg = (char *)malloc(len);
      71         147 :     int  msg_len = DeleteMsg(msg, len);
      72         147 :     assert(msg_len <= len);
      73         147 :     if (msg_len == 0) {
      74           0 :         free(msg);
      75           0 :         return true;
      76             :     }
      77         147 :     KSyncSock   *sock = KSyncSock::Get(0);
      78         147 :     sock->SendAsync(this, msg_len, msg, KSyncEntry::DEL_ACK);
      79         147 :     return false;
      80             : }
      81             : 
      82             : ///////////////////////////////////////////////////////////////////////////////
      83             : // KSyncNetlinkDBEntry routines
      84             : ///////////////////////////////////////////////////////////////////////////////
      85       17003 : bool KSyncNetlinkDBEntry::Add() {
      86       17003 :     int len = MsgLen();
      87       17003 :     char *msg = (char *)malloc(len);
      88       17003 :     int  msg_len = AddMsg(msg, len);
      89       17003 :     assert(msg_len <= len);
      90       17003 :     if (msg_len == 0) {
      91           2 :         free(msg);
      92           2 :         return true;
      93             :     }
      94       17001 :     KSyncSock   *sock = KSyncSock::Get(0);
      95       17001 :     sock->SendAsync(this, msg_len, msg, KSyncEntry::ADD_ACK);
      96       17001 :     return false;
      97             : }
      98             : 
      99        3679 : bool KSyncNetlinkDBEntry::Change() {
     100        3679 :     int len = MsgLen();
     101        3679 :     char *msg = (char *)malloc(len);
     102        3679 :     int  msg_len = ChangeMsg(msg, len);
     103        3679 :     assert(msg_len <= len);
     104        3679 :     if (msg_len == 0) {
     105           2 :         free(msg);
     106           2 :         return true;
     107             :     }
     108        3677 :     KSyncSock   *sock = KSyncSock::Get(0);
     109        3677 :     sock->SendAsync(this, msg_len, msg, KSyncEntry::CHANGE_ACK);
     110        3677 :     return false;
     111             : }
     112             : 
     113       17003 : bool KSyncNetlinkDBEntry::Delete() {
     114       17003 :     int len = MsgLen();
     115       17003 :     char *msg = (char *)malloc(len);
     116       17003 :     int  msg_len = DeleteMsg(msg, len);
     117       17003 :     assert(msg_len <= len);
     118       17003 :     if (msg_len == 0) {
     119           0 :         free(msg);
     120           0 :         return true;
     121             :     }
     122       17003 :     KSyncSock   *sock = KSyncSock::Get(0);
     123       17003 :     sock->SendAsync(this, msg_len, msg, KSyncEntry::DEL_ACK);
     124       17003 :     return false;
     125             : }

Generated by: LCOV version 1.14