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

Generated by: LCOV version 1.14