[hipl-dev] [Branch ~hipl-core/hipl/trunk] Rev 6460: Fix inefficient usage of the netlink handle

  • From: noreply@xxxxxxxxxxxxx
  • To: HIPL core team <hipl-dev@xxxxxxxxxxxxx>
  • Date: Wed, 11 Nov 2015 17:32:22 -0000

------------------------------------------------------------
revno: 6460
committer: Juhani Toivonen <juhani.toivonen@xxxxxxxxxxxxxx>
branch nick: hipl
timestamp: Wed 2015-11-11 19:32:08 +0200
message:
Fix inefficient usage of the netlink handle

A major reason for the poor performance when using hipfw, and especially LSIs
was that the netlink handle was opened, queried, and closed separately for
each packet that was processed.

The handle is now opened when hipfw starts, and closed when hipfw exits.

Fixes Bug #1515296
modified:
hipfw/hipfw.c


--
lp:hipl
https://code.launchpad.net/~hipl-core/hipl/trunk

Your team HIPL core team is subscribed to branch lp:hipl.
To unsubscribe from this branch go to
https://code.launchpad.net/~hipl-core/hipl/trunk/+edit-subscription
=== modified file 'hipfw/hipfw.c'
--- hipfw/hipfw.c 2013-09-11 10:57:49 +0000
+++ hipfw/hipfw.c 2015-11-11 17:32:08 +0000
@@ -153,6 +153,13 @@
*/
static int hip_fw_async_sock = 0;

+/**
+ * This is a handle to interface with Netlink.
+ * It should be initiated when hipfw starts, used to get information about
+ * network interfaces during packet processing, and closed when hipfw exits.
+ */
+static struct nlif_handle *nlifh;
+
/*----------------INIT FUNCTIONS------------------*/

/**
@@ -659,6 +666,9 @@

cert_uninit();

+ /* Close the netlink interface handle */
+ nlif_close(nlifh);
+
#ifdef CONFIG_HIP_PERFORMANCE
/* Deallocate memory of perf_set after finishing all of tests */
hip_perf_destroy(perf_set);
@@ -1293,6 +1303,10 @@
system_print("ip6tables -I OUTPUT -j HIPFW-OUTPUT");
system_print("ip6tables -I FORWARD -j HIPFW-FORWARD");

+ // Open handle to interface with netlink
+ HIP_IFEL( (nlifh = nlif_open()) == NULL, -1, "failed to open netlink
interface handle");
+ nlif_query(nlifh); // query the interface table
+
out_err:
return err;
}
@@ -1307,17 +1321,8 @@
static int build_ipq_packet(struct nfq_data *nfa, struct hip_ipq_packet_msg
*ptr)
{
struct nfqnl_msg_packet_hdr *ph;
- struct nlif_handle *nlifh;
ph = nfq_get_msg_packet_hdr(nfa);

- // Open handle to read interface names from
- nlifh = nlif_open();
- if (nlifh == NULL) {
- HIP_PERROR("nlif_open failed during build_ipq_packet");
- return -1;
- }
- nlif_query(nlifh); // query the interface table
-
// Populate the packet struct
ptr->packet_id = ntohl(ph->packet_id);
ptr->hook = ph->hook;
@@ -1329,8 +1334,6 @@
* us to compile on both. */
ptr->data_len = nfq_get_payload(nfa, (void *) &ptr->payload);

- // Close the interface handle
- nlif_close(nlifh);
return 1;
}


Other related posts:

  • » [hipl-dev] [Branch ~hipl-core/hipl/trunk] Rev 6460: Fix inefficient usage of the netlink handle - noreply