Skip to content

Commit

Permalink
dataplane: Fixed removed rawsocket ports.
Browse files Browse the repository at this point in the history
  • Loading branch information
hibitomo committed Dec 2, 2016
1 parent d6a71a8 commit 8c319f5
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/dataplane/mgr/sock_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ rawsock_unconfigure_interface(struct interface *ifp) {
portid = ifp->info.eth_rawsock.port_number;
pollfd[portid].events = 0;
close(pollfd[portid].fd);
pollfd[portid].fd = 0;
pollfd[portid].fd = -1;
ifindex[portid] = 0;
put_port_number(portid);

Expand Down Expand Up @@ -455,7 +455,10 @@ rawsock_port_stats(struct port *port) {
return NULL;
}

fd = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE);
if (pollfd[port->ifindex].fd == -1) {
return LAGOPUS_RESULT_OK;
}
fd = socket(AF_NETLINK, SOCK_RAW | SOCK_NONBLOCK, NETLINK_ROUTE);
if (fd == -1) {
lagopus_msg_error("netlink socket create error: %s\n", strerror(errno));
free(stats);
Expand Down Expand Up @@ -578,7 +581,9 @@ rawsock_get_stats(struct interface *ifp, datastore_interface_stats_t *stats) {
int fd;

link_stats = NULL;

if (pollfd[ifp->info.eth_rawsock.port_number].fd == -1) {
return LAGOPUS_RESULT_OK;
}
fd = socket(AF_NETLINK, SOCK_RAW | SOCK_NONBLOCK, NETLINK_ROUTE);
if (fd == -1) {
lagopus_msg_error("netlink socket create error: %s\n", strerror(errno));
Expand Down Expand Up @@ -708,6 +713,9 @@ dp_rawsock_thread_loop(__UNUSED const lagopus_thread_t *selfptr,
while (*running == true) {
struct port *port;

for (i = 0; i < portidx; i++) {
pollfd[i].revents = 0;
}
/* wait 0.1 sec. */
if (poll(pollfd, (nfds_t)portidx, 100) < 0) {
err(errno, "poll");
Expand All @@ -717,6 +725,12 @@ dp_rawsock_thread_loop(__UNUSED const lagopus_thread_t *selfptr,
clear_all_cache(flowcache);
clear_cache = false;
}
if (pollfd[i].fd == -1 ||
(pollfd[i].revents & (POLLERR | POLLHUP | POLLNVAL)) != 0) {
close(pollfd[i].fd);
pollfd[i].fd = -1; /* invalidate */
continue;
}
flowdb_rdlock(NULL);
port = dp_port_lookup(DATASTORE_INTERFACE_TYPE_ETHERNET_RAWSOCK,
(uint32_t)i);
Expand Down
4 changes: 4 additions & 0 deletions test/ryu/vsw-597.dsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
interface interface0 create -type ethernet-rawsock -device veth0
port port01 create -interface interface0
bridge bridge01 create -port port01 1 -dpid 0x1 -fail-mode standalone
bridge bridge01 enable
8 changes: 8 additions & 0 deletions test/ryu/vsw-597.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh -v
sudo ip link add veth0 type veth peer name veth1
sudo lagopus -l /dev/stdout -d -C ./vsw-597.dsl &
sleep 1
sudo ip link delete veth0
echo "bridge bridge01 config -port ~port01" | nc localhost 12345
lagosh -c show interface
lagosh -c stop

0 comments on commit 8c319f5

Please sign in to comment.