netlib: better integration of harware filtering
authorRoni Häcki <roni.haecki@inf.ethz.ch>
Wed, 12 Apr 2017 13:09:50 +0000 (15:09 +0200)
committerRoni Häcki <roni.haecki@inf.ethz.ch>
Wed, 12 Apr 2017 13:09:50 +0000 (15:09 +0200)
Signed-off-by: Roni Häcki <roni.haecki@inf.ethz.ch>

14 files changed:
errors/errno.fugu
include/devif/backends/net/e10k_devif.h
include/devif/backends/net/sfn5122f_devif.h
include/net/net.h
lib/devif/backends/net/e10k/devif_backend_e10k.c
lib/devif/backends/net/solarflare/devif_backend_solarflare.c
lib/net/dhcp.c
lib/net/include/net/net_filter.h
lib/net/net.c
lib/net/net_filter.c
lib/net/networking_internal.h
lib/net/test/udp_echo.c
usr/drivers/solarflare/Hakefile
usr/drivers/solarflare/sfn5122f_cdriver.c

index e99e5ce..416e6c9 100755 (executable)
@@ -750,6 +750,7 @@ errors filter PORT_ERR_ {
 
 //errors in Filter management
 errors filter NET_FILTER_ERR_ {
+    failure NOT_INITIALIZED      "Filter subsystem not yet initalized",
     failure NOT_FOUND           "Filter not found or not installed",
     failure ALREADY_EXISTS      "Filter already installed",
 };
index d99c780..fd228e9 100644 (file)
@@ -15,4 +15,6 @@ typedef void (*e10k_event_cb_t)(void* q);
 errval_t e10k_queue_create(struct e10k_queue** q, e10k_event_cb_t cb, 
                            bool use_vf, bool interrupts);
 errval_t e10k_queue_destroy(struct e10k_queue* q);
+
+uint64_t e10k_queue_get_id(struct e10k_queue* q);
 #endif
index f51ce6a..3eea58f 100644 (file)
@@ -15,4 +15,6 @@ typedef void (*sfn5122f_event_cb_t)(void* q);
 errval_t sfn5122f_queue_create(struct sfn5122f_queue** q, sfn5122f_event_cb_t cb, 
                                bool userspace, bool interrupts, bool default_q);
 errval_t sfn5122f_queue_destroy(struct sfn5122f_queue* q);
+
+uint64_t sfn5122f_queue_get_id(struct sfn5122f_queue* q);
 #endif
index 33feb0e..80488d1 100644 (file)
@@ -20,7 +20,6 @@
 struct devq;
 struct eth_addr;
 
-
 /*
  * ==============================================================================
  * Networking Flags
@@ -51,7 +50,6 @@ typedef uint32_t net_flags_t;
 ///< the default network interface
 #define NET_DEFAULT_NIC NULL
 
-
 /*
  * ==============================================================================
  * Library Initialization
@@ -106,7 +104,7 @@ errval_t networking_poll(void);
  *
  * @return SYS_ERR_OK on success, errval on failure
  */
-errval_t networking_create_queue(const char *cardname, uint64_t queueid,
+errval_t networking_create_queue(const char *cardname, uint64_t* queueid,
                                  struct devq **retqueue);
 
 /**
@@ -119,5 +117,36 @@ errval_t networking_create_queue(const char *cardname, uint64_t queueid,
  */
 errval_t networking_get_defaults(uint64_t *queue, const char **cardname, uint32_t *flags);
 
+/*
+ * ==============================================================================
+ * Installing filters
+ * ==============================================================================
+ */
+
+/**
+ * @brief Install L3/L4 filter
+ *
+ * @param tcp       should TCP packets be filtered or UPD
+ * @param src_ip    source ip of the filter, 0 for wildcard
+ * @param src_port  source port of the filter, 0 for wildcard
+ * @param dst_port  destination port fo the filter       
+ *
+ * @return SYS_ERR_OK on success, NET_FILTER_ERR_* on failure
+ */
+errval_t networking_install_ip_filter(bool tcp, ip_addr_t* src, 
+                                      uint16_t src_port, uint16_t dst_port);
+
+/**
+ * @brief Remove L3/L4 filter
+ *
+ * @param tcp       should TCP packets be filtered or UPD
+ * @param src_ip    source ip of the filter, 0 for wildcard
+ * @param src_port  source port of the filter, 0 for wildcard
+ * @param dst_port  destination port fo the filter       
+ *
+ * @return SYS_ERR_OK on success, NET_FILTER_ERR_* on failure
+ */
+errval_t networking_remove_ip_filter(bool tcp, ip_addr_t* src, 
+                                     uint16_t src_port, uint16_t dst_port);
 
 #endif /* LIB_NET_INCLUDE_NETWORKING_H_ */
index f60148b..4c9aa4e 100644 (file)
@@ -588,3 +588,7 @@ errval_t e10k_queue_create(struct e10k_queue** queue, e10k_event_cb_t cb,
     return SYS_ERR_OK;
 }
 
+uint64_t e10k_queue_get_id(struct e10k_queue* q)
+{
+    return q->id;
+}
index 4b33ede..84b85bb 100644 (file)
@@ -399,6 +399,7 @@ static errval_t sfn5122f_dequeue(struct devq* q, regionid_t* rid, genoffset_t* o
             err = sfn5122f_queue_handle_rx_ev_devif(queue, rid, offset, length,
                                                     valid_data, valid_length,
                                                     flags);
+
             DEBUG_QUEUE("RX_EV Q_ID: %d len %ld OK %s \n", queue->id, *valid_length,
                         err_getstring(err));
 
@@ -488,7 +489,7 @@ static void interrupt_handler(void* arg)
  *
  */
 
-errval_t sfn5122f_queue_create(struct sfn5122f_queue** q, sfn5122f_event_cb_t cb,
+errval_t sfn5122f_queue_create(struct sfn5122f_queue** q, sfn5122f_event_cb_t cb, 
                                bool userlevel, bool interrupts, bool qzero)
 {
     DEBUG_QUEUE("create called \n");
@@ -654,3 +655,9 @@ errval_t sfn5122f_queue_destroy(struct sfn5122f_queue* q)
 
     return SYS_ERR_OK;
 }
+
+
+uint64_t sfn5122f_queue_get_id(struct sfn5122f_queue* q)
+{
+    return q->id;    
+}
index fc5e549..31f2618 100644 (file)
@@ -123,7 +123,7 @@ errval_t dhcpd_start(net_flags_t flags)
     }
 
     if (flags & NET_FLAGS_BLOCKING_INIT) {
-        printf("waiting for DHCP to complete");
+        printf("waiting for DHCP to complete \n");
         while(!dhcpd_has_ip()) {
             networking_poll();
             if (st->dhcp_ticks > DHCP_TIMEOUT_MSECS / DHCP_FINE_TIMER_MSECS) {
index 27d75cd..d620107 100644 (file)
@@ -19,7 +19,7 @@
 #include <barrelfish/barrelfish.h>
 
 #define NET_FILTER_TCP 0
-#define NET_FILTER_UPD 1
+#define NET_FILTER_UDP 1
 #define NET_FILTER_MAC 2
 
 struct net_filter_ip {
@@ -37,12 +37,41 @@ struct net_filter_mac {
     uint64_t mac;
 };
 
-errval_t net_filter_init(const char* cardname);
 
-errval_t net_filter_ip_install(struct net_filter_ip* filt);
-errval_t net_filter_mac_install(struct net_filter_mac* filt);
+struct net_filter_ele {
+    union {
+        struct net_filter_ip ip;
+        struct net_filter_mac mac;
+    } filter;
+    uint64_t filter_id;
+    struct net_filter_ele* next;
+    struct net_filter_ele* prev;
+};
+
+struct filter_list {
+    struct net_filter_ele* start;
+    uint64_t num_ele;
+};
+
+struct net_filter_state {
+    struct filter_list filters_ip;
+    struct filter_list filters_mac;
+    struct net_filter_binding* b;
+    volatile bool bound;
+};
+
+errval_t net_filter_init(struct net_filter_state** st, 
+                         const char* cardname);
+
+errval_t net_filter_ip_install(struct net_filter_state* st,
+                               struct net_filter_ip* filt);
+
+errval_t net_filter_mac_install(struct net_filter_state* st,
+                                struct net_filter_mac* filt);
 
-errval_t net_filter_ip_remove(struct net_filter_ip* filt);
-errval_t net_filter_mac_remove(struct net_filter_mac* filt);
+errval_t net_filter_ip_remove(struct net_filter_state* st,
+                              struct net_filter_ip* filt);
+errval_t net_filter_mac_remove(struct net_filter_state* st,
+                               struct net_filter_mac* filt);
 
 #endif /* LIB_NET_INCLUDE_NETWORKING_FILTER_H_ */
index 8af299a..729086c 100644 (file)
@@ -61,13 +61,14 @@ static void int_handler(void* args)
     net_if_poll(&st->netif);
 }
 
-static errval_t create_loopback_queue (struct net_state *st, uint64_t queueid,
+static errval_t create_loopback_queue (struct net_state *st, uint64_t* queueid,
                                        struct devq **retqueue)
 {
     errval_t err;
 
     debug_printf("net: creating loopback queue.\n");
 
+    *queueid = 0;
     err = loopback_queue_create((struct loopback_queue **)retqueue);
     if (err_is_fail(err)) {
         return err;
@@ -76,30 +77,34 @@ static errval_t create_loopback_queue (struct net_state *st, uint64_t queueid,
     return SYS_ERR_OK;
 }
 
-static errval_t create_driver_queue (struct net_state *st, uint64_t queueid,
+static errval_t create_driver_queue (struct net_state *st, uint64_t* queueid,
                                      struct devq **retqueue)
 {
+    *queueid = 0;
     return SYS_ERR_OK;
 }
 
 
-static errval_t create_e10k_queue (struct net_state *st, uint64_t queueid,
+static errval_t create_e10k_queue (struct net_state *st, uint64_t* queueid,
                                    struct devq **retqueue)
 {
     return SYS_ERR_OK;
 }
 
-static errval_t create_sfn5122f_queue (struct net_state *st, uint64_t queueid, struct devq **retqueue)
+static errval_t create_sfn5122f_queue (struct net_state *st, uint64_t* queueid, 
+                                       struct devq **retqueue)
 {
-
-    return sfn5122f_queue_create((struct sfn5122f_queue**)retqueue, int_handler,
+    errval_t err;
+    err = sfn5122f_queue_create((struct sfn5122f_queue**)retqueue, int_handler,
                                 false /*userlevel network feature*/,
                                 !(st->flags & NET_FLAGS_POLLING) /* user interrupts*/,
                                 (st->flags & NET_FLAGS_DEFAULT_QUEUE));
+    *queueid = sfn5122f_queue_get_id((struct sfn5122f_queue*)*retqueue);
+    return err;
 }
 
 
-typedef errval_t (*queue_create_fn)(struct net_state *, uint64_t, struct devq **);
+typedef errval_t (*queue_create_fn)(struct net_state *, uint64_t*, struct devq **);
 struct networking_card
 {
     char *cardname;
@@ -123,10 +128,10 @@ struct networking_card
  * @return SYS_ERR_OK on success, errval on failure
  */
 static errval_t net_create_queue(struct net_state *st, const char *cardname,
-                                        uint64_t queueid, struct devq **retqueue)
+                                 uint64_t* queueid, struct devq **retqueue)
 {
-    debug_printf("net: creating queue for card='%s', queueid=%" PRIu64 "...\n",
-                  cardname, queueid);
+    debug_printf("net: creating queue for card='%s'...\n",
+                  cardname);
 
     struct networking_card *nc = networking_cards;
     while(nc->cardname != NULL) {
@@ -137,7 +142,7 @@ static errval_t net_create_queue(struct net_state *st, const char *cardname,
     }
 
     debug_printf("net: ERROR unknown queue. card='%s', queueid=%" PRIu64 "\n",
-                  cardname, queueid);
+                  cardname, *queueid);
 
     return -1;
 }
@@ -151,7 +156,7 @@ static errval_t net_create_queue(struct net_state *st, const char *cardname,
  *
  * @return SYS_ERR_OK on success, errval on failure
  */
-errval_t networking_create_queue(const char *cardname, uint64_t queueid,
+errval_t networking_create_queue(const char *cardname, uint64_t* queueid,
                                  struct devq **retqueue)
 {
     struct net_state *st = get_default_net_state();
@@ -225,7 +230,7 @@ static errval_t networking_init_with_queue_st(struct net_state *st,struct devq *
 
     NETDEBUG("initializing hw filter...\n");
 
-    err = net_filter_init(st->cardname);
+    err = net_filter_init(&st->filter, st->cardname);
     if (err_is_fail(err)) {
         USER_PANIC("Init filter infrastructure failed: %s \n", err_getstring(err));
     }
@@ -314,7 +319,7 @@ static errval_t networking_init_st(struct net_state *st, const char *nic,
     st->flags = flags;
 
     /* create the queue wit the given nic and card name */
-    err = networking_create_queue(st->cardname, st->queueid, &st->queue);
+    err = networking_create_queue(st->cardname, &st->queueid, &st->queue);
     if (err_is_fail(err)) {
         return err;
     }
@@ -413,3 +418,93 @@ errval_t networking_poll(void)
     struct net_state *st = &state;
     return networking_poll_st(st);
 }
+
+
+/**
+ * @brief Install L3/L4 filter
+ *
+ * @param tcp       should TCP packets be filtered or UPD
+ * @param src_ip    source ip of the filter, 0 for wildcard
+ * @param src_port  source port of the filter, 0 for wildcard
+ * @param dst_port  destination port fo the filter       
+ *
+ * @return SYS_ERR_OK on success, NET_FILTER_ERR_* on failure
+ */
+errval_t networking_install_ip_filter(bool tcp, ip_addr_t* src, 
+                                      uint16_t src_port, uint16_t dst_port)
+{
+    errval_t err;
+    if (state.filter == NULL) {
+        return NET_FILTER_ERR_NOT_INITIALIZED;
+    }
+
+    struct net_filter_state *st = state.filter;
+
+    // get current config
+    ip_addr_t dst_ip;
+    err = dhcpd_get_ipconfig(&dst_ip, NULL, NULL);
+    if (err_is_fail(err)) {
+        return err;
+    }
+    
+    struct net_filter_ip ip = {
+        .qid = state.queueid,
+        .ip_src = (uint32_t) src->addr,
+        .ip_dst = (uint32_t) dst_ip.addr,
+        .port_dst = dst_port,
+        .port_src = src_port,
+    };
+
+    if (tcp) {
+        ip.type = NET_FILTER_TCP;
+    } else {
+        ip.type = NET_FILTER_UDP;
+    }
+    
+    return net_filter_ip_install(st, &ip);
+}
+
+/**
+ * @brief Remove L3/L4 filter
+ *
+ * @param tcp       should TCP packets be filtered or UPD
+ * @param src_ip    source ip of the filter, 0 for wildcard
+ * @param src_port  source port of the filter, 0 for wildcard
+ * @param dst_port  destination port fo the filter       
+ *
+ * @return SYS_ERR_OK on success, NET_FILTER_ERR_* on failure
+ */
+errval_t networking_remove_ip_filter(bool tcp, ip_addr_t* src, 
+                                     uint16_t src_port, uint16_t dst_port)
+{
+
+    errval_t err;
+    if (state.filter == NULL) {
+        return NET_FILTER_ERR_NOT_INITIALIZED;
+    }
+
+    struct net_filter_state *st = state.filter;
+
+    // get current config
+    ip_addr_t dst_ip;
+    err = dhcpd_get_ipconfig(&dst_ip, NULL, NULL);
+    if (err_is_fail(err)) {
+        return err;
+    }
+    
+    struct net_filter_ip ip = {
+        .qid = state.queueid,
+        .ip_src = (uint32_t) src->addr,
+        .ip_dst = (uint32_t) dst_ip.addr,
+        .port_dst = dst_port,
+        .port_src = src_port,
+    };
+
+    if (tcp) {
+        ip.type = NET_FILTER_TCP;
+    } else {
+        ip.type = NET_FILTER_UDP;
+    }
+    
+    return net_filter_ip_remove(st, &ip);
+}
index d1781e5..ac35924 100644 (file)
 
 #define NETDEBUG_SUBSYSTEM "filter"
 
-struct net_filter_ele {
-    union {
-        struct net_filter_ip ip;
-        struct net_filter_mac mac;
-    } filter;
-    uint64_t filter_id;
-    struct net_filter_ele* next;
-    struct net_filter_ele* prev;
-};
-
-struct filter_list {
-    struct net_filter_ele* start;
-    uint64_t num_ele;  
-};
-
-struct net_filter_state {
-    struct filter_list filters_ip;
-    struct filter_list filters_mac;
-    struct net_filter_binding* b;
-    volatile bool bound;
-};
-
-
-/******************************************************************************
- * Global state
- ******************************************************************************/
-
-static struct net_filter_state filter_state;
-
 /******************************************************************************
  * Connection setup
  ******************************************************************************/
@@ -62,18 +33,20 @@ static struct net_filter_state filter_state;
 // Callback for bind
 static void bind_cb(void *st, errval_t err, struct net_filter_binding *b)
 {
+    struct net_filter_state* filt = (struct net_filter_state*) st;
     assert(err_is_ok(err));
 
     NETDEBUG("Sucessfully connected to management interface\n");
 
-    filter_state.b = b;
-    net_filter_rpc_client_init(filter_state.b);
-    filter_state.bound = true;
+    filt->b = b;
+    net_filter_rpc_client_init(filt->b);
+    filt->bound = true;
 }
 
 
 /** Open connection to management interface */
-static errval_t connect_to_net_filter(const char *dev_name)
+static errval_t connect_to_net_filter(struct net_filter_state* st, 
+                                      const char *dev_name)
 {
     errval_t r;
     iref_t iref;
@@ -91,14 +64,14 @@ static errval_t connect_to_net_filter(const char *dev_name)
     }
 
     NETDEBUG("Binding\n");
-    r = net_filter_bind(iref, bind_cb, &filter_state, get_default_waitset(),
+    r = net_filter_bind(iref, bind_cb, st, get_default_waitset(),
             IDC_BIND_FLAGS_DEFAULT);
     if (err_is_fail(r)) {
         return r;
     }
 
     NETDEBUG("Waiting to bind\n");
-    while(filter_state.bound == false) {
+    while(st->bound == false) {
         event_dispatch(get_default_waitset());
     }
     
@@ -157,20 +130,26 @@ static bool is_reachable(struct net_filter_ip* filt)
  * @brief initalized network filtering. Sets up connection to drivers
  *        which support hardware filtering
  *
- * @param cardname  returns the card name to be used
+ * @param st        returned net filter state;
+ * @param cardname  the card name to be used
  *
  * @return SYS_ERR_OK on success, error on failure
  */
-errval_t net_filter_init(const char* cardname)
+errval_t net_filter_init(struct net_filter_state** st, 
+                         const char* cardname)
 {   
     errval_t err;
 
-    filter_state.filters_ip.start = NULL;
-    filter_state.filters_ip.num_ele = 0;
-    filter_state.filters_mac.start = NULL;
-    filter_state.filters_mac.num_ele = 0;
+    struct net_filter_state* tmp = calloc(1, sizeof(struct net_filter_state));
+    assert(tmp != NULL);
+    
+    tmp->filters_ip.start = NULL;
+    tmp->filters_ip.num_ele = 0;
+    tmp->filters_mac.start = NULL;
+    tmp->filters_mac.num_ele = 0;
 
-    err = connect_to_net_filter(cardname);
+    err = connect_to_net_filter(tmp, cardname);
+    *st = tmp;
     return err;
 }
 
@@ -179,25 +158,27 @@ errval_t net_filter_init(const char* cardname)
  * @brief Installs an L3/L4 filter in the hardware filter 
  *        tables
  *
+ * @param st    net filter state
  * @param filt  filter struct
  *
  * @return SYS_ERR_OK on success, error on failure
  */
-errval_t net_filter_ip_install(struct net_filter_ip* filt)
+errval_t net_filter_ip_install(struct net_filter_state* st, 
+                               struct net_filter_ip* filt)
 {
 
-    assert(filter_state.bound);
+    assert(st->bound);
     errval_t err;
     uint64_t filter_id;
 
-    struct net_filter_ele* cur = filter_state.filters_ip.start;
+    struct net_filter_ele* cur = st->filters_ip.start;
     struct net_filter_ele* prev = NULL;
 
     /* go through linked list and find last element 
      (and check if filter is already installed) */
     if (cur == NULL) {
-        filter_state.filters_ip.start = malloc(sizeof(struct net_filter_ele));
-        cur = filter_state.filters_ip.start;
+        st->filters_ip.start = malloc(sizeof(struct net_filter_ele));
+        cur = st->filters_ip.start;
     } else {
         while(cur->next != NULL) {
             if (filter_cmp_ip(&cur->filter.ip, filt)) {
@@ -224,16 +205,16 @@ errval_t net_filter_ip_install(struct net_filter_ip* filt)
     cur->next = NULL;
     cur->prev = prev;    
 
-    filter_state.filters_ip.num_ele++;
+    st->filters_ip.num_ele++;
 
-    err = filter_state.b->rpc_tx_vtbl.install_filter_ip(filter_state.b,
-                                                 filt->type,
-                                                 filt->qid,
-                                                 filt->ip_src,
-                                                 filt->ip_dst,
-                                                 filt->port_src,
-                                                 filt->port_dst,
-                                                 &filter_id);
+    err = st->b->rpc_tx_vtbl.install_filter_ip(st->b,
+                                               filt->type,
+                                               filt->qid,
+                                               filt->ip_src,
+                                               filt->ip_dst,
+                                               filt->port_src,
+                                               filt->port_dst,
+                                               &filter_id);
     if (err_is_fail(err)) {
         free(cur);
         return err;
@@ -248,18 +229,20 @@ errval_t net_filter_ip_install(struct net_filter_ip* filt)
  * @brief Removes an L3/L4 filter in the hardware filter 
  *        tables
  *
+ * @param st    net filter state
  * @param filt  filter struct
  *
  * @return SYS_ERR_OK on success, error on failure
  */
-errval_t net_filter_ip_remove(struct net_filter_ip* filt)
+errval_t net_filter_ip_remove(struct net_filter_state* st, 
+                              struct net_filter_ip* filt)
 {
 
-    assert(filter_state.bound);
+    assert(st->bound);
     errval_t err, err2;
     uint64_t filter_id = (uint64_t)-1;
 
-    struct net_filter_ele* cur = filter_state.filters_ip.start;
+    struct net_filter_ele* cur = st->filters_ip.start;
     struct net_filter_ele* prev = NULL;
 
 
@@ -272,7 +255,6 @@ errval_t net_filter_ip_remove(struct net_filter_ip* filt)
     while(cur != NULL) {
         if (filter_cmp_ip(&cur->filter.ip, filt)) {
             filter_id = cur->filter_id;
-            printf("Break \n");
             break;
         }
         prev = cur;
@@ -284,10 +266,10 @@ errval_t net_filter_ip_remove(struct net_filter_ip* filt)
         return NET_FILTER_ERR_NOT_FOUND;
     }
 
-    err = filter_state.b->rpc_tx_vtbl.remove_filter(filter_state.b,
-                                                    filt->type,
-                                                    filter_id,
-                                                    &err2);
+    err = st->b->rpc_tx_vtbl.remove_filter(st->b,
+                                           filt->type,
+                                           filter_id,
+                                           &err2);
     if (err_is_fail(err) || err_is_fail(err2)) {
         return err_is_fail(err) ? err: err2;
     }
@@ -297,29 +279,28 @@ errval_t net_filter_ip_remove(struct net_filter_ip* filt)
         prev->next = cur->next;
         if (cur->next != NULL) { // check if last
             cur->next->prev = prev;
-            printf("cur->next->prev id %d \n", cur->next->prev->filter.ip.port_dst);
-            printf("prev->next id %d \n", prev->next->filter.ip.port_dst);
         } 
     } else {
-        printf("start id %d \n", filter_state.filters_ip.start->filter.ip.port_dst);
-        filter_state.filters_ip.start = cur->next;
+        st->filters_ip.start = cur->next;
     }
     
 
     free(cur);
 
-    filter_state.filters_ip.num_ele--;
+    st->filters_ip.num_ele--;
 
     return SYS_ERR_OK;
 }
 
-errval_t net_filter_mac_install(struct net_filter_mac* filt)
+errval_t net_filter_mac_install(struct net_filter_state* st,
+                                struct net_filter_mac* filt)
 {
    USER_PANIC("NYI \n");
 }
 
 
-errval_t net_filter_mac_remove(struct net_filter_mac* filt)
+errval_t net_filter_mac_remove(struct net_filter_state* st,
+                               struct net_filter_mac* filt)
 {
    USER_PANIC("NYI \n");
 }
index 877ccaa..7eb3992 100644 (file)
@@ -26,6 +26,7 @@
 
 #include <lwip/netif.h>
 
+#include <net/net_filter.h>
 #include <net/net.h>
 #include <net/netbufs.h>
 #include <net/netif.h>
@@ -67,6 +68,7 @@ struct net_state {
     struct devq *queue;
     struct net_buf_pool *pool;
     struct netif netif;
+    struct net_filter_state* filter;
 
   //  ip4_addr_t ipaddr, netmask, gw;
 };
index 1cca341..738ce25 100644 (file)
@@ -13,6 +13,7 @@
  */
 
 #include <barrelfish/barrelfish.h>
+#include <barrelfish/deferred.h>
 
 #include <lwip/ip.h>
 #include <lwip/udp.h>
@@ -48,7 +49,6 @@ int main(int argc, char *argv[])
     errval_t err;
 
     debug_printf("UDP ECHO started.\n");
-
     /* connect to the network */
     err = networking_init_default();
     if (err_is_fail(err)) {
@@ -71,16 +71,8 @@ int main(int argc, char *argv[])
         return(r);
     }
 
-    struct net_filter_ip ip;
-    ip.qid = 1;
-    ip.ip_src = 0;
-    // TODO 10.110.4.39 get this from somewhere
-    ip.ip_dst = 0x2704710A;
-    ip.port_dst = 7;
-    ip.port_src = 0;
-    ip.type = NET_FILTER_UPD;
-
-    err = net_filter_ip_install(&ip);    
+    err = networking_install_ip_filter(false, (ip_addr_t*) IP_ADDR_ANY, 
+                                       0, UDP_ECHOSERVER_PORT);    
     if (err_is_fail(err)) {
         USER_PANIC("Adding filter failed %s \n", err_getstring(err));
     }
index 86b38d3..a75bb56 100644 (file)
@@ -26,7 +26,7 @@
                       addIncludes  = [ "/lib/net/include/", "/lib/lwip-2.0.2/src/include/" ],
                       addLibraries = libDeps["netQmng", "pci", "contmng", 
                                              "net_device_manager", "bench", "trace", "skb",
-                                             "spawndomain", "netd" , "net"]
+                                             "spawndomain", "netd" , "net", "lwip2"]
                     }
   ]
 
index 63728d1..a56d46b 100644 (file)
 #include <barrelfish/nameservice_client.h>
 #include <barrelfish/deferred.h>
 #include <barrelfish/debug.h>
-#include <net/net.h>
 #include <pci/pci.h>
 
 // TODO only required for htonl
-#include <lwip/ip4_addr.h>
+#include <lwip/ip.h>
+#include <net/net.h>
 
 #include <if/sfn5122f_defs.h>
 #include <if/sfn5122f_devif_defs.h>
@@ -1641,8 +1641,7 @@ int main(int argc, char** argv)
             pci_device = PCI_DONT_CARE;
             pci_function = 0;
         } else {
-            if ((pci_vendor != PCI_VENDOR_SOLARFLARE) || (pci_devid != DEVICE_ID) ||
-                (pci_function != 0)) {
+            if ((pci_vendor != PCI_VENDOR_SOLARFLARE) || (pci_devid != DEVICE_ID)) {
                 printf("VENDOR/DEVICE ID MISMATCH: %x/%x %x/%x \n",
                         pci_vendor, PCI_VENDOR_SOLARFLARE, pci_devid, DEVICE_ID);
             }