git://git.onelab.eu
/
sliver-openvswitch.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
For SNAT, don't store the pre-fragment L2 header before actions are applied.
[sliver-openvswitch.git]
/
lib
/
vconn-stream.c
diff --git
a/lib/vconn-stream.c
b/lib/vconn-stream.c
index
c419d53
..
0b85261
100644
(file)
--- a/
lib/vconn-stream.c
+++ b/
lib/vconn-stream.c
@@
-40,13
+40,13
@@
#include <string.h>
#include <sys/types.h>
#include <unistd.h>
#include <string.h>
#include <sys/types.h>
#include <unistd.h>
-#include "buffer.h"
-#include "util.h"
-#include "openflow.h"
+#include "ofpbuf.h"
+#include "openflow/openflow.h"
#include "poll-loop.h"
#include "socket-util.h"
#include "poll-loop.h"
#include "socket-util.h"
-#include "
vconn
.h"
+#include "
util
.h"
#include "vconn-provider.h"
#include "vconn-provider.h"
+#include "vconn.h"
#include "vlog.h"
#define THIS_MODULE VLM_vconn_stream
#include "vlog.h"
#define THIS_MODULE VLM_vconn_stream
@@
-57,8
+57,8
@@
struct stream_vconn
{
struct vconn vconn;
int fd;
{
struct vconn vconn;
int fd;
- struct
buffer
*rxbuf;
- struct
buffer
*txbuf;
+ struct
ofpbuf
*rxbuf;
+ struct
ofpbuf
*txbuf;
struct poll_waiter *tx_waiter;
};
struct poll_waiter *tx_waiter;
};
@@
-66,6
+66,8
@@
static struct vconn_class stream_vconn_class;
static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(10, 25);
static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(10, 25);
+static void stream_clear_txbuf(struct stream_vconn *);
+
int
new_stream_vconn(const char *name, int fd, int connect_status,
uint32_t ip, struct vconn **vconnp)
int
new_stream_vconn(const char *name, int fd, int connect_status,
uint32_t ip, struct vconn **vconnp)
@@
-85,7
+87,7
@@
new_stream_vconn(const char *name, int fd, int connect_status,
static struct stream_vconn *
stream_vconn_cast(struct vconn *vconn)
{
static struct stream_vconn *
stream_vconn_cast(struct vconn *vconn)
{
-
assert(vconn->class ==
&stream_vconn_class);
+
vconn_assert_class(vconn,
&stream_vconn_class);
return CONTAINER_OF(vconn, struct stream_vconn, vconn);
}
return CONTAINER_OF(vconn, struct stream_vconn, vconn);
}
@@
-94,6
+96,8
@@
stream_close(struct vconn *vconn)
{
struct stream_vconn *s = stream_vconn_cast(vconn);
poll_cancel(s->tx_waiter);
{
struct stream_vconn *s = stream_vconn_cast(vconn);
poll_cancel(s->tx_waiter);
+ stream_clear_txbuf(s);
+ ofpbuf_delete(s->rxbuf);
close(s->fd);
free(s);
}
close(s->fd);
free(s);
}
@@
-106,15
+110,15
@@
stream_connect(struct vconn *vconn)
}
static int
}
static int
-stream_recv(struct vconn *vconn, struct
buffer
**bufferp)
+stream_recv(struct vconn *vconn, struct
ofpbuf
**bufferp)
{
struct stream_vconn *s = stream_vconn_cast(vconn);
{
struct stream_vconn *s = stream_vconn_cast(vconn);
- struct
buffer
*rx;
+ struct
ofpbuf
*rx;
size_t want_bytes;
ssize_t retval;
if (s->rxbuf == NULL) {
size_t want_bytes;
ssize_t retval;
if (s->rxbuf == NULL) {
- s->rxbuf =
buffer
_new(1564);
+ s->rxbuf =
ofpbuf
_new(1564);
}
rx = s->rxbuf;
}
rx = s->rxbuf;
@@
-136,9
+140,9
@@
again:
return 0;
}
}
return 0;
}
}
-
buffer
_prealloc_tailroom(rx, want_bytes);
+
ofpbuf
_prealloc_tailroom(rx, want_bytes);
- retval = read(s->fd,
buffer
_tail(rx), want_bytes);
+ retval = read(s->fd,
ofpbuf
_tail(rx), want_bytes);
if (retval > 0) {
rx->size += retval;
if (retval == want_bytes) {
if (retval > 0) {
rx->size += retval;
if (retval == want_bytes) {
@@
-159,14
+163,14
@@
again:
return EOF;
}
} else {
return EOF;
}
} else {
- return
retval ? errno : EAGAIN
;
+ return
errno
;
}
}
static void
stream_clear_txbuf(struct stream_vconn *s)
{
}
}
static void
stream_clear_txbuf(struct stream_vconn *s)
{
-
buffer
_delete(s->txbuf);
+
ofpbuf
_delete(s->txbuf);
s->txbuf = NULL;
s->tx_waiter = NULL;
}
s->txbuf = NULL;
s->tx_waiter = NULL;
}
@@
-184,7
+188,7
@@
stream_do_tx(int fd UNUSED, short int revents UNUSED, void *vconn_)
return;
}
} else if (n > 0) {
return;
}
} else if (n > 0) {
-
buffer
_pull(s->txbuf, n);
+
ofpbuf
_pull(s->txbuf, n);
if (!s->txbuf->size) {
stream_clear_txbuf(s);
return;
if (!s->txbuf->size) {
stream_clear_txbuf(s);
return;
@@
-194,7
+198,7
@@
stream_do_tx(int fd UNUSED, short int revents UNUSED, void *vconn_)
}
static int
}
static int
-stream_send(struct vconn *vconn, struct
buffer
*buffer)
+stream_send(struct vconn *vconn, struct
ofpbuf
*buffer)
{
struct stream_vconn *s = stream_vconn_cast(vconn);
ssize_t retval;
{
struct stream_vconn *s = stream_vconn_cast(vconn);
ssize_t retval;
@@
-205,12
+209,12
@@
stream_send(struct vconn *vconn, struct buffer *buffer)
retval = write(s->fd, buffer->data, buffer->size);
if (retval == buffer->size) {
retval = write(s->fd, buffer->data, buffer->size);
if (retval == buffer->size) {
-
buffer
_delete(buffer);
+
ofpbuf
_delete(buffer);
return 0;
} else if (retval >= 0 || errno == EAGAIN) {
s->txbuf = buffer;
if (retval > 0) {
return 0;
} else if (retval >= 0 || errno == EAGAIN) {
s->txbuf = buffer;
if (retval > 0) {
-
buffer
_pull(buffer, retval);
+
ofpbuf
_pull(buffer, retval);
}
s->tx_waiter = poll_fd_callback(s->fd, POLLOUT, stream_do_tx, vconn);
return 0;
}
s->tx_waiter = poll_fd_callback(s->fd, POLLOUT, stream_do_tx, vconn);
return 0;
@@
-246,40
+250,41
@@
stream_wait(struct vconn *vconn, enum vconn_wait_type wait)
}
static struct vconn_class stream_vconn_class = {
}
static struct vconn_class stream_vconn_class = {
- .name = "stream",
- .close = stream_close,
- .connect = stream_connect,
- .recv = stream_recv,
- .send = stream_send,
- .wait = stream_wait,
+ "stream", /* name */
+ NULL, /* open */
+ stream_close, /* close */
+ stream_connect, /* connect */
+ stream_recv, /* recv */
+ stream_send, /* send */
+ stream_wait, /* wait */
};
\f
/* Passive stream socket vconn. */
};
\f
/* Passive stream socket vconn. */
-struct pstream_vconn
+struct pstream_
p
vconn
{
{
- struct
vconn
vconn;
+ struct
pvconn p
vconn;
int fd;
int (*accept_cb)(int fd, const struct sockaddr *, size_t sa_len,
struct vconn **);
};
int fd;
int (*accept_cb)(int fd, const struct sockaddr *, size_t sa_len,
struct vconn **);
};
-static struct
vconn_class pstream_
vconn_class;
+static struct
pvconn_class pstream_p
vconn_class;
-static struct pstream_vconn *
-pstream_
vconn_cast(struct vconn *
vconn)
+static struct pstream_
p
vconn *
+pstream_
pvconn_cast(struct pvconn *p
vconn)
{
{
-
assert(vconn->class == &pstream_
vconn_class);
- return CONTAINER_OF(
vconn, struct pstream_vconn,
vconn);
+
pvconn_assert_class(pvconn, &pstream_p
vconn_class);
+ return CONTAINER_OF(
pvconn, struct pstream_pvconn, p
vconn);
}
int
}
int
-new_pstream_vconn(const char *name, int fd,
+new_pstream_
p
vconn(const char *name, int fd,
int (*accept_cb)(int fd, const struct sockaddr *,
size_t sa_len, struct vconn **),
int (*accept_cb)(int fd, const struct sockaddr *,
size_t sa_len, struct vconn **),
- struct
vconn **
vconnp)
+ struct
pvconn **p
vconnp)
{
{
- struct pstream_vconn *ps;
+ struct pstream_
p
vconn *ps;
int retval;
retval = set_nonblocking(fd);
int retval;
retval = set_nonblocking(fd);
@@
-296,26
+301,25
@@
new_pstream_vconn(const char *name, int fd,
}
ps = xmalloc(sizeof *ps);
}
ps = xmalloc(sizeof *ps);
- ps->vconn.class = &pstream_vconn_class;
- ps->vconn.connect_status = 0;
+ pvconn_init(&ps->pvconn, &pstream_pvconn_class, name);
ps->fd = fd;
ps->accept_cb = accept_cb;
ps->fd = fd;
ps->accept_cb = accept_cb;
- *
vconnp = &ps->
vconn;
+ *
pvconnp = &ps->p
vconn;
return 0;
}
static void
return 0;
}
static void
-pstream_close(struct
vconn *
vconn)
+pstream_close(struct
pvconn *p
vconn)
{
{
- struct pstream_
vconn *ps = pstream_vconn_cast(
vconn);
+ struct pstream_
pvconn *ps = pstream_pvconn_cast(p
vconn);
close(ps->fd);
free(ps);
}
static int
close(ps->fd);
free(ps);
}
static int
-pstream_accept(struct
vconn *
vconn, struct vconn **new_vconnp)
+pstream_accept(struct
pvconn *p
vconn, struct vconn **new_vconnp)
{
{
- struct pstream_
vconn *ps = pstream_vconn_cast(
vconn);
+ struct pstream_
pvconn *ps = pstream_pvconn_cast(p
vconn);
struct sockaddr_storage ss;
socklen_t ss_len = sizeof ss;
int new_fd;
struct sockaddr_storage ss;
socklen_t ss_len = sizeof ss;
int new_fd;
@@
-341,16
+345,16
@@
pstream_accept(struct vconn *vconn, struct vconn **new_vconnp)
}
static void
}
static void
-pstream_wait(struct
vconn *vconn, enum vconn_wait_type wait
)
+pstream_wait(struct
pvconn *pvconn
)
{
{
- struct pstream_vconn *ps = pstream_vconn_cast(vconn);
- assert(wait == WAIT_ACCEPT);
+ struct pstream_pvconn *ps = pstream_pvconn_cast(pvconn);
poll_fd_wait(ps->fd, POLLIN);
}
poll_fd_wait(ps->fd, POLLIN);
}
-static struct vconn_class pstream_vconn_class = {
- .name = "pstream",
- .close = pstream_close,
- .accept = pstream_accept,
- .wait = pstream_wait
+static struct pvconn_class pstream_pvconn_class = {
+ "pstream",
+ NULL,
+ pstream_close,
+ pstream_accept,
+ pstream_wait
};
};