From 7f4eb885ffcec5f97842aea43b64c28654e76659 Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Thu, 5 Jun 2014 09:35:39 +0000 Subject: [PATCH] some preparations for netem and irq affinity stuff git-svn-id: https://zerberus.eonerc.rwth-aachen.de:8443/svn/s2ss/trunk@60 8ec27952-4edc-4aab-86aa-e87bb2611832 --- include/node.h | 6 ++++++ src/node.c | 17 +++++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/include/node.h b/include/node.h index f9520d611..d03fd8bda 100644 --- a/include/node.h +++ b/include/node.h @@ -48,6 +48,12 @@ struct node /// Remote address of the socket struct sockaddr_in remote; + /// Name of the local interface + const char *ifname; + /// Index of the local interface + int ifindex; + /// Socket Mark + int mark; /// A short identifier of the node const char *name; diff --git a/src/node.c b/src/node.c index 90528eb8e..360f5a3f8 100644 --- a/src/node.c +++ b/src/node.c @@ -19,6 +19,7 @@ #include "utils.h" #include "msg.h" #include "node.h" +#include "if.h" int node_create(struct node *n, const char *name, enum node_type type, struct sockaddr_in local, struct sockaddr_in remote) @@ -29,6 +30,10 @@ int node_create(struct node *n, const char *name, enum node_type type, n->local = local; n->remote = remote; + /* We use to local address to determine the outgoing interface */ + //n->ifname = if_addrtoname((struct sockaddr*) &local); + //n->ifindex = if_nametoindex(n->ifname); + return 0; } @@ -41,8 +46,16 @@ int node_connect(struct node *n) /* Set socket options */ int prio = SOCKET_PRIO; - if (setsockopt(n->sd, SOL_SOCKET, SOCKET_PRIO, &prio, sizeof(prio))) - perror("Failed to set socket options"); + if (setsockopt(n->sd, SOL_SOCKET, SO_PRIORITY, &prio, sizeof(prio))) + perror("Failed to set socket priority"); + else + debug(4, "Set socket priority of node '%s' to %u", n->name, prio); + + /* Set mark for outgoing packets */ + if (setsockopt(n->sd, SOL_SOCKET, SO_MARK, &n->mark, sizeof(n->mark))) + perror("Failed to set mark for outgoing packets"); + else + debug(4, "Set mark of outgoing packets of node '%s' to %u", n->name, n->mark); /* Bind socket for receiving */ if (bind(n->sd, (struct sockaddr *) &n->local, sizeof(struct sockaddr_in)))