@@ -25,58 +25,59 @@
#include "util.h"
static void
-dp_packet_init__(struct dp_packet *b, size_t allocated, enum dp_packet_source source)
-{
- dp_packet_set_allocated(b, allocated);
- b->source = source;
- dp_packet_reset_offsets(b);
- pkt_metadata_init(&b->md, 0);
- dp_packet_reset_cutlen(b);
- dp_packet_reset_offload(b);
+dp_packet_init__(struct dp_packet *p, size_t allocated,
+ enum dp_packet_source source)
+{
+ dp_packet_set_allocated(p, allocated);
+ p->source = source;
+ dp_packet_reset_offsets(p);
+ pkt_metadata_init(&p->md, 0);
+ dp_packet_reset_cutlen(p);
+ dp_packet_reset_offload(p);
/* Initialize implementation-specific fields of dp_packet. */
- dp_packet_init_specific(b);
+ dp_packet_init_specific(p);
/* By default assume the packet type to be Ethernet. */
- b->packet_type = htonl(PT_ETH);
+ p->packet_type = htonl(PT_ETH);
}
static void
-dp_packet_use__(struct dp_packet *b, void *base, size_t allocated,
+dp_packet_use__(struct dp_packet *p, void *base, size_t allocated,
enum dp_packet_source source)
{
- dp_packet_set_base(b, base);
- dp_packet_set_data(b, base);
- dp_packet_set_size(b, 0);
+ dp_packet_set_base(p, base);
+ dp_packet_set_data(p, base);
+ dp_packet_set_size(p, 0);
- dp_packet_init__(b, allocated, source);
+ dp_packet_init__(p, allocated, source);
}
-/* Initializes 'b' as an empty dp_packet that contains the 'allocated' bytes of
+/* Initializes 'p' as an empty dp_packet that contains the 'allocated' bytes of
* memory starting at 'base'. 'base' should be the first byte of a region
- * obtained from malloc(). It will be freed (with free()) if 'b' is resized or
+ * obtained from malloc(). It will be freed (with free()) if 'p' is resized or
* freed. */
void
-dp_packet_use(struct dp_packet *b, void *base, size_t allocated)
+dp_packet_use(struct dp_packet *p, void *base, size_t allocated)
{
- dp_packet_use__(b, base, allocated, DPBUF_MALLOC);
+ dp_packet_use__(p, base, allocated, DPBUF_MALLOC);
}
#if HAVE_AF_XDP
-/* Initialize 'b' as an empty dp_packet that contains
+/* Initialize 'p' as an empty dp_packet that contains
* memory starting at AF_XDP umem base.
*/
void
-dp_packet_use_afxdp(struct dp_packet *b, void *data, size_t allocated,
+dp_packet_use_afxdp(struct dp_packet *p, void *data, size_t allocated,
size_t headroom)
{
- dp_packet_set_base(b, (char *)data - headroom);
- dp_packet_set_data(b, data);
- dp_packet_set_size(b, 0);
+ dp_packet_set_base(p, (char *) data - headroom);
+ dp_packet_set_data(p, data);
+ dp_packet_set_size(p, 0);
- dp_packet_init__(b, allocated, DPBUF_AFXDP);
+ dp_packet_init__(p, allocated, DPBUF_AFXDP);
}
#endif
-/* Initializes 'b' as an empty dp_packet that contains the 'allocated' bytes of
+/* Initializes 'p' as an empty dp_packet that contains the 'allocated' bytes of
* memory starting at 'base'. 'base' should point to a buffer on the stack.
* (Nothing actually relies on 'base' being allocated on the stack. It could
* be static or malloc()'d memory. But stack space is the most common use
@@ -91,56 +92,56 @@ dp_packet_use_afxdp(struct dp_packet *b, void *data, size_t allocated,
* on an dp_packet initialized by this function, so that if it expanded into the
* heap, that memory is freed. */
void
-dp_packet_use_stub(struct dp_packet *b, void *base, size_t allocated)
+dp_packet_use_stub(struct dp_packet *p, void *base, size_t allocated)
{
- dp_packet_use__(b, base, allocated, DPBUF_STUB);
+ dp_packet_use__(p, base, allocated, DPBUF_STUB);
}
-/* Initializes 'b' as an dp_packet whose data starts at 'data' and continues for
- * 'size' bytes. This is appropriate for an dp_packet that will be used to
- * inspect existing data, without moving it around or reallocating it, and
+/* Initializes 'p' as an dp_packet whose data starts at 'data' and continues
+ * for 'size' bytes. This is appropriate for an dp_packet that will be used
+ * to inspect existing data, without moving it around or reallocating it, and
* generally without modifying it at all.
*
* An dp_packet operation that requires reallocating data will assert-fail if this
* function was used to initialize it. */
void
-dp_packet_use_const(struct dp_packet *b, const void *data, size_t size)
+dp_packet_use_const(struct dp_packet *p, const void *data, size_t size)
{
- dp_packet_use__(b, CONST_CAST(void *, data), size, DPBUF_STACK);
- dp_packet_set_size(b, size);
+ dp_packet_use__(p, CONST_CAST(void *, data), size, DPBUF_STACK);
+ dp_packet_set_size(p, size);
}
-/* Initializes 'b' as a DPDK dp-packet, which must have been allocated from a
+/* Initializes 'p' as a DPDK dp-packet, which must have been allocated from a
* DPDK memory pool. */
void
-dp_packet_init_dpdk(struct dp_packet *b)
+dp_packet_init_dpdk(struct dp_packet *p)
{
- b->source = DPBUF_DPDK;
+ p->source = DPBUF_DPDK;
}
-/* Initializes 'b' as an empty dp_packet with an initial capacity of 'size'
+/* Initializes 'p' as an empty dp_packet with an initial capacity of 'size'
* bytes. */
void
-dp_packet_init(struct dp_packet *b, size_t size)
+dp_packet_init(struct dp_packet *p, size_t size)
{
- dp_packet_use(b, size ? xmalloc(size) : NULL, size);
+ dp_packet_use(p, size ? xmalloc(size) : NULL, size);
}
-/* Frees memory that 'b' points to. */
+/* Frees memory that 'p' points to. */
void
-dp_packet_uninit(struct dp_packet *b)
+dp_packet_uninit(struct dp_packet *p)
{
- if (b) {
- if (b->source == DPBUF_MALLOC) {
- free(dp_packet_base(b));
- } else if (b->source == DPBUF_DPDK) {
+ if (p) {
+ if (p->source == DPBUF_MALLOC) {
+ free(dp_packet_base(p));
+ } else if (p->source == DPBUF_DPDK) {
#ifdef DPDK_NETDEV
/* If this dp_packet was allocated by DPDK it must have been
* created as a dp_packet */
- free_dpdk_buf((struct dp_packet*) b);
+ free_dpdk_buf((struct dp_packet *) p);
#endif
- } else if (b->source == DPBUF_AFXDP) {
- free_afxdp_buf(b);
+ } else if (p->source == DPBUF_AFXDP) {
+ free_afxdp_buf(p);
}
}
}
@@ -150,9 +151,9 @@ dp_packet_uninit(struct dp_packet *b)
struct dp_packet *
dp_packet_new(size_t size)
{
- struct dp_packet *b = xmalloc(sizeof *b);
- dp_packet_init(b, size);
- return b;
+ struct dp_packet *p = xmalloc(sizeof *p);
+ dp_packet_init(p, size);
+ return p;
}
/* Creates and returns a new dp_packet with an initial capacity of 'size +
@@ -160,45 +161,45 @@ dp_packet_new(size_t size)
struct dp_packet *
dp_packet_new_with_headroom(size_t size, size_t headroom)
{
- struct dp_packet *b = dp_packet_new(size + headroom);
- dp_packet_reserve(b, headroom);
- return b;
+ struct dp_packet *p = dp_packet_new(size + headroom);
+ dp_packet_reserve(p, headroom);
+ return p;
}
/* Creates and returns a new dp_packet that initially contains a copy of the
- * 'dp_packet_size(buffer)' bytes of data starting at 'buffer->data' with no headroom or
+ * 'dp_packet_size(p)' bytes of data starting at 'p->data' with no headroom or
* tailroom. */
struct dp_packet *
-dp_packet_clone(const struct dp_packet *buffer)
+dp_packet_clone(const struct dp_packet *p)
{
- return dp_packet_clone_with_headroom(buffer, 0);
+ return dp_packet_clone_with_headroom(p, 0);
}
-/* Creates and returns a new dp_packet whose data are copied from 'buffer'.
+/* Creates and returns a new dp_packet whose data are copied from 'p'.
* The returned dp_packet will additionally have 'headroom' bytes of
* headroom. */
struct dp_packet *
-dp_packet_clone_with_headroom(const struct dp_packet *buffer, size_t headroom)
+dp_packet_clone_with_headroom(const struct dp_packet *p, size_t headroom)
{
struct dp_packet *new_buffer;
uint32_t mark;
- new_buffer = dp_packet_clone_data_with_headroom(dp_packet_data(buffer),
- dp_packet_size(buffer),
- headroom);
+ new_buffer = dp_packet_clone_data_with_headroom(dp_packet_data(p),
+ dp_packet_size(p),
+ headroom);
/* Copy the following fields into the returned buffer: l2_pad_size,
* l2_5_ofs, l3_ofs, l4_ofs, cutlen, packet_type and md. */
- memcpy(&new_buffer->l2_pad_size, &buffer->l2_pad_size,
+ memcpy(&new_buffer->l2_pad_size, &p->l2_pad_size,
sizeof(struct dp_packet) -
offsetof(struct dp_packet, l2_pad_size));
- *dp_packet_ol_flags_ptr(new_buffer) = *dp_packet_ol_flags_ptr(buffer);
+ *dp_packet_ol_flags_ptr(new_buffer) = *dp_packet_ol_flags_ptr(p);
*dp_packet_ol_flags_ptr(new_buffer) &= DP_PACKET_OL_SUPPORTED_MASK;
- if (dp_packet_rss_valid(buffer)) {
- dp_packet_set_rss_hash(new_buffer, dp_packet_get_rss_hash(buffer));
+ if (dp_packet_rss_valid(p)) {
+ dp_packet_set_rss_hash(new_buffer, dp_packet_get_rss_hash(p));
}
- if (dp_packet_has_flow_mark(buffer, &mark)) {
+ if (dp_packet_has_flow_mark(p, &mark)) {
dp_packet_set_flow_mark(new_buffer, mark);
}
@@ -219,47 +220,47 @@ dp_packet_clone_data(const void *data, size_t size)
struct dp_packet *
dp_packet_clone_data_with_headroom(const void *data, size_t size, size_t headroom)
{
- struct dp_packet *b = dp_packet_new_with_headroom(size, headroom);
- dp_packet_put(b, data, size);
- return b;
+ struct dp_packet *p = dp_packet_new_with_headroom(size, headroom);
+ dp_packet_put(p, data, size);
+ return p;
}
static void
-dp_packet_copy__(struct dp_packet *b, uint8_t *new_base,
+dp_packet_copy__(struct dp_packet *p, uint8_t *new_base,
size_t new_headroom, size_t new_tailroom)
{
- const uint8_t *old_base = dp_packet_base(b);
- size_t old_headroom = dp_packet_headroom(b);
- size_t old_tailroom = dp_packet_tailroom(b);
+ const uint8_t *old_base = dp_packet_base(p);
+ size_t old_headroom = dp_packet_headroom(p);
+ size_t old_tailroom = dp_packet_tailroom(p);
size_t copy_headroom = MIN(old_headroom, new_headroom);
size_t copy_tailroom = MIN(old_tailroom, new_tailroom);
memcpy(&new_base[new_headroom - copy_headroom],
&old_base[old_headroom - copy_headroom],
- copy_headroom + dp_packet_size(b) + copy_tailroom);
+ copy_headroom + dp_packet_size(p) + copy_tailroom);
}
-/* Reallocates 'b' so that it has exactly 'new_headroom' and 'new_tailroom'
+/* Reallocates 'p' so that it has exactly 'new_headroom' and 'new_tailroom'
* bytes of headroom and tailroom, respectively. */
void
-dp_packet_resize(struct dp_packet *b, size_t new_headroom, size_t new_tailroom)
+dp_packet_resize(struct dp_packet *p, size_t new_headroom, size_t new_tailroom)
{
void *new_base, *new_data;
size_t new_allocated;
- new_allocated = new_headroom + dp_packet_size(b) + new_tailroom;
+ new_allocated = new_headroom + dp_packet_size(p) + new_tailroom;
- switch (b->source) {
+ switch (p->source) {
case DPBUF_DPDK:
OVS_NOT_REACHED();
case DPBUF_MALLOC:
- if (new_headroom == dp_packet_headroom(b)) {
- new_base = xrealloc(dp_packet_base(b), new_allocated);
+ if (new_headroom == dp_packet_headroom(p)) {
+ new_base = xrealloc(dp_packet_base(p), new_allocated);
} else {
new_base = xmalloc(new_allocated);
- dp_packet_copy__(b, new_base, new_headroom, new_tailroom);
- free(dp_packet_base(b));
+ dp_packet_copy__(p, new_base, new_headroom, new_tailroom);
+ free(dp_packet_base(p));
}
break;
@@ -270,108 +271,108 @@ dp_packet_resize(struct dp_packet *b, size_t new_headroom, size_t new_tailroom)
OVS_NOT_REACHED();
case DPBUF_STUB:
- b->source = DPBUF_MALLOC;
+ p->source = DPBUF_MALLOC;
new_base = xmalloc(new_allocated);
- dp_packet_copy__(b, new_base, new_headroom, new_tailroom);
+ dp_packet_copy__(p, new_base, new_headroom, new_tailroom);
break;
default:
OVS_NOT_REACHED();
}
- dp_packet_set_allocated(b, new_allocated);
- dp_packet_set_base(b, new_base);
+ dp_packet_set_allocated(p, new_allocated);
+ dp_packet_set_base(p, new_base);
new_data = (char *) new_base + new_headroom;
- if (dp_packet_data(b) != new_data) {
- dp_packet_set_data(b, new_data);
+ if (dp_packet_data(p) != new_data) {
+ dp_packet_set_data(p, new_data);
}
}
-/* Ensures that 'b' has room for at least 'size' bytes at its tail end,
+/* Ensures that 'p' has room for at least 'size' bytes at its tail end,
* reallocating and copying its data if necessary. Its headroom, if any, is
* preserved. */
void
-dp_packet_prealloc_tailroom(struct dp_packet *b, size_t size)
+dp_packet_prealloc_tailroom(struct dp_packet *p, size_t size)
{
- if ((size && !dp_packet_base(b)) || (size > dp_packet_tailroom(b))) {
- dp_packet_resize(b, dp_packet_headroom(b), MAX(size, 64));
+ if ((size && !dp_packet_base(p)) || (size > dp_packet_tailroom(p))) {
+ dp_packet_resize(p, dp_packet_headroom(p), MAX(size, 64));
}
}
-/* Ensures that 'b' has room for at least 'size' bytes at its head,
+/* Ensures that 'p' has room for at least 'size' bytes at its head,
* reallocating and copying its data if necessary. Its tailroom, if any, is
* preserved. */
void
-dp_packet_prealloc_headroom(struct dp_packet *b, size_t size)
+dp_packet_prealloc_headroom(struct dp_packet *p, size_t size)
{
- if (size > dp_packet_headroom(b)) {
- dp_packet_resize(b, MAX(size, 64), dp_packet_tailroom(b));
+ if (size > dp_packet_headroom(p)) {
+ dp_packet_resize(p, MAX(size, 64), dp_packet_tailroom(p));
}
}
-/* Shifts all of the data within the allocated space in 'b' by 'delta' bytes.
+/* Shifts all of the data within the allocated space in 'p' by 'delta' bytes.
* For example, a 'delta' of 1 would cause each byte of data to move one byte
* forward (from address 'p' to 'p+1'), and a 'delta' of -1 would cause each
* byte to move one byte backward (from 'p' to 'p-1'). */
void
-dp_packet_shift(struct dp_packet *b, int delta)
+dp_packet_shift(struct dp_packet *p, int delta)
{
- ovs_assert(delta > 0 ? delta <= dp_packet_tailroom(b)
- : delta < 0 ? -delta <= dp_packet_headroom(b)
+ ovs_assert(delta > 0 ? delta <= dp_packet_tailroom(p)
+ : delta < 0 ? -delta <= dp_packet_headroom(p)
: true);
if (delta != 0) {
- char *dst = (char *) dp_packet_data(b) + delta;
- memmove(dst, dp_packet_data(b), dp_packet_size(b));
- dp_packet_set_data(b, dst);
+ char *dst = (char *) dp_packet_data(p) + delta;
+ memmove(dst, dp_packet_data(p), dp_packet_size(p));
+ dp_packet_set_data(p, dst);
}
}
-/* Appends 'size' bytes of data to the tail end of 'b', reallocating and
+/* Appends 'size' bytes of data to the tail end of 'p', reallocating and
* copying its data if necessary. Returns a pointer to the first byte of the
* new data, which is left uninitialized. */
void *
-dp_packet_put_uninit(struct dp_packet *b, size_t size)
+dp_packet_put_uninit(struct dp_packet *p, size_t size)
{
- void *p;
- dp_packet_prealloc_tailroom(b, size);
- p = dp_packet_tail(b);
- dp_packet_set_size(b, dp_packet_size(b) + size);
- return p;
+ void *tail;
+ dp_packet_prealloc_tailroom(p, size);
+ tail = dp_packet_tail(p);
+ dp_packet_set_size(p, dp_packet_size(p) + size);
+ return tail;
}
-/* Appends 'size' zeroed bytes to the tail end of 'b'. Data in 'b' is
+/* Appends 'size' zeroed bytes to the tail end of 'p'. Data in 'p' is
* reallocated and copied if necessary. Returns a pointer to the first byte of
* the data's location in the dp_packet. */
void *
-dp_packet_put_zeros(struct dp_packet *b, size_t size)
+dp_packet_put_zeros(struct dp_packet *p, size_t size)
{
- void *dst = dp_packet_put_uninit(b, size);
+ void *dst = dp_packet_put_uninit(p, size);
memset(dst, 0, size);
return dst;
}
-/* Appends the 'size' bytes of data in 'p' to the tail end of 'b'. Data in 'b'
+/* Appends the 'size' bytes of data in 'p' to the tail end of 'p'. Data in 'p'
* is reallocated and copied if necessary. Returns a pointer to the first
* byte of the data's location in the dp_packet. */
void *
-dp_packet_put(struct dp_packet *b, const void *p, size_t size)
+dp_packet_put(struct dp_packet *p, const void *data, size_t size)
{
- void *dst = dp_packet_put_uninit(b, size);
- memcpy(dst, p, size);
+ void *dst = dp_packet_put_uninit(p, size);
+ memcpy(dst, data, size);
return dst;
}
/* Parses as many pairs of hex digits as possible (possibly separated by
- * spaces) from the beginning of 's', appending bytes for their values to 'b'.
+ * spaces) from the beginning of 's', appending bytes for their values to 'p'.
* Returns the first character of 's' that is not the first of a pair of hex
- * digits. If 'n' is nonnull, stores the number of bytes added to 'b' in
+ * digits. If 'n' is nonnull, stores the number of bytes added to 'p' in
* '*n'. */
char *
-dp_packet_put_hex(struct dp_packet *b, const char *s, size_t *n)
+dp_packet_put_hex(struct dp_packet *p, const char *s, size_t *n)
{
- size_t initial_size = dp_packet_size(b);
+ size_t initial_size = dp_packet_size(p);
for (;;) {
uint8_t byte;
bool ok;
@@ -380,12 +381,12 @@ dp_packet_put_hex(struct dp_packet *b, const char *s, size_t *n)
byte = hexits_value(s, 2, &ok);
if (!ok) {
if (n) {
- *n = dp_packet_size(b) - initial_size;
+ *n = dp_packet_size(p) - initial_size;
}
return CONST_CAST(char *, s);
}
- dp_packet_put(b, &byte, 1);
+ dp_packet_put(p, &byte, 1);
s += 2;
}
}
@@ -393,80 +394,80 @@ dp_packet_put_hex(struct dp_packet *b, const char *s, size_t *n)
/* Reserves 'size' bytes of headroom so that they can be later allocated with
* dp_packet_push_uninit() without reallocating the dp_packet. */
void
-dp_packet_reserve(struct dp_packet *b, size_t size)
+dp_packet_reserve(struct dp_packet *p, size_t size)
{
- ovs_assert(!dp_packet_size(b));
- dp_packet_prealloc_tailroom(b, size);
- dp_packet_set_data(b, (char*)dp_packet_data(b) + size);
+ ovs_assert(!dp_packet_size(p));
+ dp_packet_prealloc_tailroom(p, size);
+ dp_packet_set_data(p, (char *) dp_packet_data(p) + size);
}
/* Reserves 'headroom' bytes at the head and 'tailroom' at the end so that
* they can be later allocated with dp_packet_push_uninit() or
* dp_packet_put_uninit() without reallocating the dp_packet. */
void
-dp_packet_reserve_with_tailroom(struct dp_packet *b, size_t headroom,
+dp_packet_reserve_with_tailroom(struct dp_packet *p, size_t headroom,
size_t tailroom)
{
- ovs_assert(!dp_packet_size(b));
- dp_packet_prealloc_tailroom(b, headroom + tailroom);
- dp_packet_set_data(b, (char*)dp_packet_data(b) + headroom);
+ ovs_assert(!dp_packet_size(p));
+ dp_packet_prealloc_tailroom(p, headroom + tailroom);
+ dp_packet_set_data(p, (char *) dp_packet_data(p) + headroom);
}
-/* Prefixes 'size' bytes to the head end of 'b', reallocating and copying its
+/* Prefixes 'size' bytes to the head end of 'p', reallocating and copying its
* data if necessary. Returns a pointer to the first byte of the data's
* location in the dp_packet. The new data is left uninitialized. */
void *
-dp_packet_push_uninit(struct dp_packet *b, size_t size)
+dp_packet_push_uninit(struct dp_packet *p, size_t size)
{
- dp_packet_prealloc_headroom(b, size);
- dp_packet_set_data(b, (char*)dp_packet_data(b) - size);
- dp_packet_set_size(b, dp_packet_size(b) + size);
- return dp_packet_data(b);
+ dp_packet_prealloc_headroom(p, size);
+ dp_packet_set_data(p, (char *) dp_packet_data(p) - size);
+ dp_packet_set_size(p, dp_packet_size(p) + size);
+ return dp_packet_data(p);
}
-/* Prefixes 'size' zeroed bytes to the head end of 'b', reallocating and
+/* Prefixes 'size' zeroed bytes to the head end of 'p', reallocating and
* copying its data if necessary. Returns a pointer to the first byte of the
* data's location in the dp_packet. */
void *
-dp_packet_push_zeros(struct dp_packet *b, size_t size)
+dp_packet_push_zeros(struct dp_packet *p, size_t size)
{
- void *dst = dp_packet_push_uninit(b, size);
+ void *dst = dp_packet_push_uninit(p, size);
memset(dst, 0, size);
return dst;
}
-/* Copies the 'size' bytes starting at 'p' to the head end of 'b', reallocating
- * and copying its data if necessary. Returns a pointer to the first byte of
- * the data's location in the dp_packet. */
+/* Copies the 'size' bytes starting at 'data' to the head end of 'p',
+ * reallocating and copying its data if necessary. Returns a pointer to
+ * the first byte of the data's location in the dp_packet. */
void *
-dp_packet_push(struct dp_packet *b, const void *p, size_t size)
+dp_packet_push(struct dp_packet *p, const void *data, size_t size)
{
- void *dst = dp_packet_push_uninit(b, size);
- memcpy(dst, p, size);
+ void *dst = dp_packet_push_uninit(p, size);
+ memcpy(dst, data, size);
return dst;
}
-/* Returns the data in 'b' as a block of malloc()'d memory and frees the buffer
- * within 'b'. (If 'b' itself was dynamically allocated, e.g. with
+/* Returns the data in 'p' as a block of malloc()'d memory and frees the buffer
+ * within 'p'. (If 'p' itself was dynamically allocated, e.g. with
* dp_packet_new(), then it should still be freed with, e.g., dp_packet_delete().) */
void *
-dp_packet_steal_data(struct dp_packet *b)
+dp_packet_steal_data(struct dp_packet *p)
{
- void *p;
- ovs_assert(b->source != DPBUF_DPDK);
- ovs_assert(b->source != DPBUF_AFXDP);
+ void *data;
+ ovs_assert(p->source != DPBUF_DPDK);
+ ovs_assert(p->source != DPBUF_AFXDP);
- if (b->source == DPBUF_MALLOC && dp_packet_data(b) == dp_packet_base(b)) {
- p = dp_packet_data(b);
+ if (p->source == DPBUF_MALLOC && dp_packet_data(p) == dp_packet_base(p)) {
+ data = dp_packet_data(p);
} else {
- p = xmemdup(dp_packet_data(b), dp_packet_size(b));
- if (b->source == DPBUF_MALLOC) {
- free(dp_packet_base(b));
+ data = xmemdup(dp_packet_data(p), dp_packet_size(p));
+ if (p->source == DPBUF_MALLOC) {
+ free(dp_packet_base(p));
}
}
- dp_packet_set_base(b, NULL);
- dp_packet_set_data(b, NULL);
- return p;
+ dp_packet_set_base(p, NULL);
+ dp_packet_set_data(p, NULL);
+ return data;
}
static inline void
@@ -481,28 +482,28 @@ dp_packet_adjust_layer_offset(uint16_t *offset, int increment)
* pointer and the layer offsets. The caller is responsible for
* modifying the contents. */
void *
-dp_packet_resize_l2_5(struct dp_packet *b, int increment)
+dp_packet_resize_l2_5(struct dp_packet *p, int increment)
{
if (increment >= 0) {
- dp_packet_push_uninit(b, increment);
+ dp_packet_push_uninit(p, increment);
} else {
- dp_packet_pull(b, -increment);
+ dp_packet_pull(p, -increment);
}
/* Adjust layer offsets after l2_5. */
- dp_packet_adjust_layer_offset(&b->l3_ofs, increment);
- dp_packet_adjust_layer_offset(&b->l4_ofs, increment);
+ dp_packet_adjust_layer_offset(&p->l3_ofs, increment);
+ dp_packet_adjust_layer_offset(&p->l4_ofs, increment);
- return dp_packet_data(b);
+ return dp_packet_data(p);
}
/* Adjust the size of the l2 portion of the dp_packet, updating the l2
* pointer and the layer offsets. The caller is responsible for
* modifying the contents. */
void *
-dp_packet_resize_l2(struct dp_packet *b, int increment)
+dp_packet_resize_l2(struct dp_packet *p, int increment)
{
- dp_packet_resize_l2_5(b, increment);
- dp_packet_adjust_layer_offset(&b->l2_5_ofs, increment);
- return dp_packet_data(b);
+ dp_packet_resize_l2_5(p, increment);
+ dp_packet_adjust_layer_offset(&p->l2_5_ofs, increment);
+ return dp_packet_data(p);
}
@@ -198,7 +198,7 @@ struct dp_packet *dp_packet_clone_with_headroom(const struct dp_packet *,
struct dp_packet *dp_packet_clone_data(const void *, size_t);
struct dp_packet *dp_packet_clone_data_with_headroom(const void *, size_t,
size_t headroom);
-void dp_packet_resize(struct dp_packet *b, size_t new_headroom,
+void dp_packet_resize(struct dp_packet *p, size_t new_headroom,
size_t new_tailroom);
static inline void dp_packet_delete(struct dp_packet *);
static inline void dp_packet_swap(struct dp_packet *, struct dp_packet *);
@@ -237,25 +237,25 @@ static inline bool dp_packet_equal(const struct dp_packet *,
const struct dp_packet *);
-/* Frees memory that 'b' points to, as well as 'b' itself. */
+/* Frees memory that 'p' points to, as well as 'p' itself. */
static inline void
-dp_packet_delete(struct dp_packet *b)
+dp_packet_delete(struct dp_packet *p)
{
- if (b) {
- if (b->source == DPBUF_DPDK) {
+ if (p) {
+ if (p->source == DPBUF_DPDK) {
/* If this dp_packet was allocated by DPDK it must have been
* created as a dp_packet */
- free_dpdk_buf((struct dp_packet*) b);
+ free_dpdk_buf((struct dp_packet *) p);
return;
}
- if (b->source == DPBUF_AFXDP) {
- free_afxdp_buf(b);
+ if (p->source == DPBUF_AFXDP) {
+ free_afxdp_buf(p);
return;
}
- dp_packet_uninit(b);
- free(b);
+ dp_packet_uninit(p);
+ free(p);
}
}
@@ -271,86 +271,86 @@ dp_packet_swap(struct dp_packet *a, struct dp_packet *b)
*b = c;
}
-/* If 'b' contains at least 'offset + size' bytes of data, returns a pointer to
+/* If 'p' contains at least 'offset + size' bytes of data, returns a pointer to
* byte 'offset'. Otherwise, returns a null pointer. */
static inline void *
-dp_packet_at(const struct dp_packet *b, size_t offset, size_t size)
+dp_packet_at(const struct dp_packet *p, size_t offset, size_t size)
{
- return offset + size <= dp_packet_size(b)
- ? (char *) dp_packet_data(b) + offset
+ return offset + size <= dp_packet_size(p)
+ ? (char *) dp_packet_data(p) + offset
: NULL;
}
-/* Returns a pointer to byte 'offset' in 'b', which must contain at least
+/* Returns a pointer to byte 'offset' in 'p', which must contain at least
* 'offset + size' bytes of data. */
static inline void *
-dp_packet_at_assert(const struct dp_packet *b, size_t offset, size_t size)
+dp_packet_at_assert(const struct dp_packet *p, size_t offset, size_t size)
{
- ovs_assert(offset + size <= dp_packet_size(b));
- return ((char *) dp_packet_data(b)) + offset;
+ ovs_assert(offset + size <= dp_packet_size(p));
+ return ((char *) dp_packet_data(p)) + offset;
}
-/* Returns a pointer to byte following the last byte of data in use in 'b'. */
+/* Returns a pointer to byte following the last byte of data in use in 'p'. */
static inline void *
-dp_packet_tail(const struct dp_packet *b)
+dp_packet_tail(const struct dp_packet *p)
{
- return (char *) dp_packet_data(b) + dp_packet_size(b);
+ return (char *) dp_packet_data(p) + dp_packet_size(p);
}
/* Returns a pointer to byte following the last byte allocated for use (but
- * not necessarily in use) in 'b'. */
+ * not necessarily in use) in 'p'. */
static inline void *
-dp_packet_end(const struct dp_packet *b)
+dp_packet_end(const struct dp_packet *p)
{
- return (char *) dp_packet_base(b) + dp_packet_get_allocated(b);
+ return (char *) dp_packet_base(p) + dp_packet_get_allocated(p);
}
-/* Returns the number of bytes of headroom in 'b', that is, the number of bytes
- * of unused space in dp_packet 'b' before the data that is in use. (Most
+/* Returns the number of bytes of headroom in 'p', that is, the number of bytes
+ * of unused space in dp_packet 'p' before the data that is in use. (Most
* commonly, the data in a dp_packet is at its beginning, and thus the
* dp_packet's headroom is 0.) */
static inline size_t
-dp_packet_headroom(const struct dp_packet *b)
+dp_packet_headroom(const struct dp_packet *p)
{
- return (char *) dp_packet_data(b) - (char *) dp_packet_base(b);
+ return (char *) dp_packet_data(p) - (char *) dp_packet_base(p);
}
/* Returns the number of bytes that may be appended to the tail end of
- * dp_packet 'b' before the dp_packet must be reallocated. */
+ * dp_packet 'p' before the dp_packet must be reallocated. */
static inline size_t
-dp_packet_tailroom(const struct dp_packet *b)
+dp_packet_tailroom(const struct dp_packet *p)
{
- return (char *) dp_packet_end(b) - (char *) dp_packet_tail(b);
+ return (char *) dp_packet_end(p) - (char *) dp_packet_tail(p);
}
-/* Clears any data from 'b'. */
+/* Clears any data from 'p'. */
static inline void
-dp_packet_clear(struct dp_packet *b)
+dp_packet_clear(struct dp_packet *p)
{
- dp_packet_set_data(b, dp_packet_base(b));
- dp_packet_set_size(b, 0);
+ dp_packet_set_data(p, dp_packet_base(p));
+ dp_packet_set_size(p, 0);
}
-/* Removes 'size' bytes from the head end of 'b', which must contain at least
+/* Removes 'size' bytes from the head end of 'p', which must contain at least
* 'size' bytes of data. Returns the first byte of data removed. */
static inline void *
-dp_packet_pull(struct dp_packet *b, size_t size)
+dp_packet_pull(struct dp_packet *p, size_t size)
{
- void *data = dp_packet_data(b);
- ovs_assert(dp_packet_size(b) - dp_packet_l2_pad_size(b) >= size);
- dp_packet_set_data(b, (char *) dp_packet_data(b) + size);
- dp_packet_set_size(b, dp_packet_size(b) - size);
+ void *data = dp_packet_data(p);
+ ovs_assert(dp_packet_size(p) - dp_packet_l2_pad_size(p) >= size);
+ dp_packet_set_data(p, (char *) dp_packet_data(p) + size);
+ dp_packet_set_size(p, dp_packet_size(p) - size);
return data;
}
-/* If 'b' has at least 'size' bytes of data, removes that many bytes from the
- * head end of 'b' and returns the first byte removed. Otherwise, returns a
- * null pointer without modifying 'b'. */
+/* If 'p' has at least 'size' bytes of data, removes that many bytes from the
+ * head end of 'p' and returns the first byte removed. Otherwise, returns a
+ * null pointer without modifying 'p'. */
static inline void *
-dp_packet_try_pull(struct dp_packet *b, size_t size)
+dp_packet_try_pull(struct dp_packet *p, size_t size)
{
- return dp_packet_size(b) - dp_packet_l2_pad_size(b) >= size
- ? dp_packet_pull(b, size) : NULL;
+ return dp_packet_size(p) - dp_packet_l2_pad_size(p) >= size
+ ? dp_packet_pull(p, size) : NULL;
}
static inline bool
@@ -361,117 +361,117 @@ dp_packet_equal(const struct dp_packet *a, const struct dp_packet *b)
}
static inline bool
-dp_packet_is_eth(const struct dp_packet *b)
+dp_packet_is_eth(const struct dp_packet *p)
{
- return b->packet_type == htonl(PT_ETH);
+ return p->packet_type == htonl(PT_ETH);
}
/* Get the start of the Ethernet frame. 'l3_ofs' marks the end of the l2
* headers, so return NULL if it is not set. */
static inline void *
-dp_packet_eth(const struct dp_packet *b)
+dp_packet_eth(const struct dp_packet *p)
{
- return (dp_packet_is_eth(b) && b->l3_ofs != UINT16_MAX)
- ? dp_packet_data(b) : NULL;
+ return (dp_packet_is_eth(p) && p->l3_ofs != UINT16_MAX)
+ ? dp_packet_data(p) : NULL;
}
/* Resets all layer offsets. 'l3' offset must be set before 'l2' can be
* retrieved. */
static inline void
-dp_packet_reset_offsets(struct dp_packet *b)
+dp_packet_reset_offsets(struct dp_packet *p)
{
- b->l2_pad_size = 0;
- b->l2_5_ofs = UINT16_MAX;
- b->l3_ofs = UINT16_MAX;
- b->l4_ofs = UINT16_MAX;
+ p->l2_pad_size = 0;
+ p->l2_5_ofs = UINT16_MAX;
+ p->l3_ofs = UINT16_MAX;
+ p->l4_ofs = UINT16_MAX;
}
static inline uint16_t
-dp_packet_l2_pad_size(const struct dp_packet *b)
+dp_packet_l2_pad_size(const struct dp_packet *p)
{
- return b->l2_pad_size;
+ return p->l2_pad_size;
}
static inline void
-dp_packet_set_l2_pad_size(struct dp_packet *b, uint16_t pad_size)
+dp_packet_set_l2_pad_size(struct dp_packet *p, uint16_t pad_size)
{
- ovs_assert(pad_size <= dp_packet_size(b));
- b->l2_pad_size = pad_size;
+ ovs_assert(pad_size <= dp_packet_size(p));
+ p->l2_pad_size = pad_size;
}
static inline void *
-dp_packet_l2_5(const struct dp_packet *b)
+dp_packet_l2_5(const struct dp_packet *p)
{
- return b->l2_5_ofs != UINT16_MAX
- ? (char *) dp_packet_data(b) + b->l2_5_ofs
+ return p->l2_5_ofs != UINT16_MAX
+ ? (char *) dp_packet_data(p) + p->l2_5_ofs
: NULL;
}
static inline void
-dp_packet_set_l2_5(struct dp_packet *b, void *l2_5)
+dp_packet_set_l2_5(struct dp_packet *p, void *l2_5)
{
- b->l2_5_ofs = l2_5
- ? (char *) l2_5 - (char *) dp_packet_data(b)
+ p->l2_5_ofs = l2_5
+ ? (char *) l2_5 - (char *) dp_packet_data(p)
: UINT16_MAX;
}
static inline void *
-dp_packet_l3(const struct dp_packet *b)
+dp_packet_l3(const struct dp_packet *p)
{
- return b->l3_ofs != UINT16_MAX
- ? (char *) dp_packet_data(b) + b->l3_ofs
+ return p->l3_ofs != UINT16_MAX
+ ? (char *) dp_packet_data(p) + p->l3_ofs
: NULL;
}
static inline void
-dp_packet_set_l3(struct dp_packet *b, void *l3)
+dp_packet_set_l3(struct dp_packet *p, void *l3)
{
- b->l3_ofs = l3 ? (char *) l3 - (char *) dp_packet_data(b) : UINT16_MAX;
+ p->l3_ofs = l3 ? (char *) l3 - (char *) dp_packet_data(p) : UINT16_MAX;
}
static inline void *
-dp_packet_l4(const struct dp_packet *b)
+dp_packet_l4(const struct dp_packet *p)
{
- return b->l4_ofs != UINT16_MAX
- ? (char *) dp_packet_data(b) + b->l4_ofs
+ return p->l4_ofs != UINT16_MAX
+ ? (char *) dp_packet_data(p) + p->l4_ofs
: NULL;
}
static inline void
-dp_packet_set_l4(struct dp_packet *b, void *l4)
+dp_packet_set_l4(struct dp_packet *p, void *l4)
{
- b->l4_ofs = l4 ? (char *) l4 - (char *) dp_packet_data(b) : UINT16_MAX;
+ p->l4_ofs = l4 ? (char *) l4 - (char *) dp_packet_data(p) : UINT16_MAX;
}
/* Returns the size of the packet from the beginning of the L3 header to the
* end of the L3 payload. Hence L2 padding is not included. */
static inline size_t
-dp_packet_l3_size(const struct dp_packet *b)
+dp_packet_l3_size(const struct dp_packet *p)
{
- return OVS_LIKELY(b->l3_ofs != UINT16_MAX)
- ? (const char *)dp_packet_tail(b) - (const char *)dp_packet_l3(b)
- - dp_packet_l2_pad_size(b)
+ return OVS_LIKELY(p->l3_ofs != UINT16_MAX)
+ ? (const char *) dp_packet_tail(p) - (const char *) dp_packet_l3(p)
+ - dp_packet_l2_pad_size(p)
: 0;
}
/* Returns the size of the packet from the beginning of the L4 header to the
* end of the L4 payload. Hence L2 padding is not included. */
static inline size_t
-dp_packet_l4_size(const struct dp_packet *b)
+dp_packet_l4_size(const struct dp_packet *p)
{
- return OVS_LIKELY(b->l4_ofs != UINT16_MAX)
- ? (const char *)dp_packet_tail(b) - (const char *)dp_packet_l4(b)
- - dp_packet_l2_pad_size(b)
+ return OVS_LIKELY(p->l4_ofs != UINT16_MAX)
+ ? (const char *) dp_packet_tail(p) - (const char *) dp_packet_l4(p)
+ - dp_packet_l2_pad_size(p)
: 0;
}
static inline const void *
-dp_packet_get_tcp_payload(const struct dp_packet *b)
+dp_packet_get_tcp_payload(const struct dp_packet *p)
{
- size_t l4_size = dp_packet_l4_size(b);
+ size_t l4_size = dp_packet_l4_size(p);
if (OVS_LIKELY(l4_size >= TCP_HEADER_LEN)) {
- struct tcp_header *tcp = dp_packet_l4(b);
+ struct tcp_header *tcp = dp_packet_l4(p);
int tcp_len = TCP_OFFSET(tcp->tcp_ctl) * 4;
if (OVS_LIKELY(tcp_len >= TCP_HEADER_LEN && tcp_len <= l4_size)) {
@@ -482,11 +482,11 @@ dp_packet_get_tcp_payload(const struct dp_packet *b)
}
static inline uint32_t
-dp_packet_get_tcp_payload_length(const struct dp_packet *pkt)
+dp_packet_get_tcp_payload_length(const struct dp_packet *p)
{
- const char *tcp_payload = dp_packet_get_tcp_payload(pkt);
+ const char *tcp_payload = dp_packet_get_tcp_payload(p);
if (tcp_payload) {
- return ((char *) dp_packet_tail(pkt) - dp_packet_l2_pad_size(pkt)
+ return ((char *) dp_packet_tail(p) - dp_packet_l2_pad_size(p)
- tcp_payload);
} else {
return 0;
@@ -494,69 +494,69 @@ dp_packet_get_tcp_payload_length(const struct dp_packet *pkt)
}
static inline const void *
-dp_packet_get_udp_payload(const struct dp_packet *b)
+dp_packet_get_udp_payload(const struct dp_packet *p)
{
- return OVS_LIKELY(dp_packet_l4_size(b) >= UDP_HEADER_LEN)
- ? (const char *)dp_packet_l4(b) + UDP_HEADER_LEN : NULL;
+ return OVS_LIKELY(dp_packet_l4_size(p) >= UDP_HEADER_LEN)
+ ? (const char *) dp_packet_l4(p) + UDP_HEADER_LEN : NULL;
}
static inline const void *
-dp_packet_get_sctp_payload(const struct dp_packet *b)
+dp_packet_get_sctp_payload(const struct dp_packet *p)
{
- return OVS_LIKELY(dp_packet_l4_size(b) >= SCTP_HEADER_LEN)
- ? (const char *)dp_packet_l4(b) + SCTP_HEADER_LEN : NULL;
+ return OVS_LIKELY(dp_packet_l4_size(p) >= SCTP_HEADER_LEN)
+ ? (const char *) dp_packet_l4(p) + SCTP_HEADER_LEN : NULL;
}
static inline const void *
-dp_packet_get_icmp_payload(const struct dp_packet *b)
+dp_packet_get_icmp_payload(const struct dp_packet *p)
{
- return OVS_LIKELY(dp_packet_l4_size(b) >= ICMP_HEADER_LEN)
- ? (const char *)dp_packet_l4(b) + ICMP_HEADER_LEN : NULL;
+ return OVS_LIKELY(dp_packet_l4_size(p) >= ICMP_HEADER_LEN)
+ ? (const char *) dp_packet_l4(p) + ICMP_HEADER_LEN : NULL;
}
static inline const void *
-dp_packet_get_nd_payload(const struct dp_packet *b)
+dp_packet_get_nd_payload(const struct dp_packet *p)
{
- return OVS_LIKELY(dp_packet_l4_size(b) >= ND_MSG_LEN)
- ? (const char *)dp_packet_l4(b) + ND_MSG_LEN : NULL;
+ return OVS_LIKELY(dp_packet_l4_size(p) >= ND_MSG_LEN)
+ ? (const char *) dp_packet_l4(p) + ND_MSG_LEN : NULL;
}
#ifdef DPDK_NETDEV
static inline uint64_t *
-dp_packet_ol_flags_ptr(const struct dp_packet *b)
+dp_packet_ol_flags_ptr(const struct dp_packet *p)
{
- return CONST_CAST(uint64_t *, &b->mbuf.ol_flags);
+ return CONST_CAST(uint64_t *, &p->mbuf.ol_flags);
}
static inline uint32_t *
-dp_packet_rss_ptr(const struct dp_packet *b)
+dp_packet_rss_ptr(const struct dp_packet *p)
{
- return CONST_CAST(uint32_t *, &b->mbuf.hash.rss);
+ return CONST_CAST(uint32_t *, &p->mbuf.hash.rss);
}
static inline uint32_t *
-dp_packet_flow_mark_ptr(const struct dp_packet *b)
+dp_packet_flow_mark_ptr(const struct dp_packet *p)
{
- return CONST_CAST(uint32_t *, &b->mbuf.hash.fdir.hi);
+ return CONST_CAST(uint32_t *, &p->mbuf.hash.fdir.hi);
}
#else
static inline uint32_t *
-dp_packet_ol_flags_ptr(const struct dp_packet *b)
+dp_packet_ol_flags_ptr(const struct dp_packet *p)
{
- return CONST_CAST(uint32_t *, &b->ol_flags);
+ return CONST_CAST(uint32_t *, &p->ol_flags);
}
static inline uint32_t *
-dp_packet_rss_ptr(const struct dp_packet *b)
+dp_packet_rss_ptr(const struct dp_packet *p)
{
- return CONST_CAST(uint32_t *, &b->rss_hash);
+ return CONST_CAST(uint32_t *, &p->rss_hash);
}
static inline uint32_t *
-dp_packet_flow_mark_ptr(const struct dp_packet *b)
+dp_packet_flow_mark_ptr(const struct dp_packet *p)
{
- return CONST_CAST(uint32_t *, &b->flow_mark);
+ return CONST_CAST(uint32_t *, &p->flow_mark);
}
#endif
@@ -574,25 +574,25 @@ dp_packet_init_specific(struct dp_packet *p)
}
static inline void *
-dp_packet_base(const struct dp_packet *b)
+dp_packet_base(const struct dp_packet *p)
{
- return b->mbuf.buf_addr;
+ return p->mbuf.buf_addr;
}
static inline void
-dp_packet_set_base(struct dp_packet *b, void *d)
+dp_packet_set_base(struct dp_packet *p, void *d)
{
- b->mbuf.buf_addr = d;
+ p->mbuf.buf_addr = d;
}
static inline uint32_t
-dp_packet_size(const struct dp_packet *b)
+dp_packet_size(const struct dp_packet *p)
{
- return b->mbuf.pkt_len;
+ return p->mbuf.pkt_len;
}
static inline void
-dp_packet_set_size(struct dp_packet *b, uint32_t v)
+dp_packet_set_size(struct dp_packet *p, uint32_t v)
{
/* netdev-dpdk does not currently support segmentation; consequently, for
* all intents and purposes, 'data_len' (16 bit) and 'pkt_len' (32 bit) may
@@ -602,33 +602,33 @@ dp_packet_set_size(struct dp_packet *b, uint32_t v)
* (and thus 'v') will always be <= UINT16_MAX; this means that there is no
* loss of accuracy in assigning 'v' to 'data_len'.
*/
- b->mbuf.data_len = (uint16_t)v; /* Current seg length. */
- b->mbuf.pkt_len = v; /* Total length of all segments linked to
+ p->mbuf.data_len = (uint16_t) v; /* Current seg length. */
+ p->mbuf.pkt_len = v; /* Total length of all segments linked to
* this segment. */
}
static inline uint16_t
-__packet_data(const struct dp_packet *b)
+__packet_data(const struct dp_packet *p)
{
- return b->mbuf.data_off;
+ return p->mbuf.data_off;
}
static inline void
-__packet_set_data(struct dp_packet *b, uint16_t v)
+__packet_set_data(struct dp_packet *p, uint16_t v)
{
- b->mbuf.data_off = v;
+ p->mbuf.data_off = v;
}
static inline uint16_t
-dp_packet_get_allocated(const struct dp_packet *b)
+dp_packet_get_allocated(const struct dp_packet *p)
{
- return b->mbuf.buf_len;
+ return p->mbuf.buf_len;
}
static inline void
-dp_packet_set_allocated(struct dp_packet *b, uint16_t s)
+dp_packet_set_allocated(struct dp_packet *p, uint16_t s)
{
- b->mbuf.buf_len = s;
+ p->mbuf.buf_len = s;
}
#else /* DPDK_NETDEV */
@@ -640,112 +640,112 @@ dp_packet_init_specific(struct dp_packet *p OVS_UNUSED)
}
static inline void *
-dp_packet_base(const struct dp_packet *b)
+dp_packet_base(const struct dp_packet *p)
{
- return b->base_;
+ return p->base_;
}
static inline void
-dp_packet_set_base(struct dp_packet *b, void *d)
+dp_packet_set_base(struct dp_packet *p, void *d)
{
- b->base_ = d;
+ p->base_ = d;
}
static inline uint32_t
-dp_packet_size(const struct dp_packet *b)
+dp_packet_size(const struct dp_packet *p)
{
- return b->size_;
+ return p->size_;
}
static inline void
-dp_packet_set_size(struct dp_packet *b, uint32_t v)
+dp_packet_set_size(struct dp_packet *p, uint32_t v)
{
- b->size_ = v;
+ p->size_ = v;
}
static inline uint16_t
-__packet_data(const struct dp_packet *b)
+__packet_data(const struct dp_packet *p)
{
- return b->data_ofs;
+ return p->data_ofs;
}
static inline void
-__packet_set_data(struct dp_packet *b, uint16_t v)
+__packet_set_data(struct dp_packet *p, uint16_t v)
{
- b->data_ofs = v;
+ p->data_ofs = v;
}
static inline uint16_t
-dp_packet_get_allocated(const struct dp_packet *b)
+dp_packet_get_allocated(const struct dp_packet *p)
{
- return b->allocated_;
+ return p->allocated_;
}
static inline void
-dp_packet_set_allocated(struct dp_packet *b, uint16_t s)
+dp_packet_set_allocated(struct dp_packet *p, uint16_t s)
{
- b->allocated_ = s;
+ p->allocated_ = s;
}
#endif /* DPDK_NETDEV */
static inline void
-dp_packet_reset_cutlen(struct dp_packet *b)
+dp_packet_reset_cutlen(struct dp_packet *p)
{
- b->cutlen = 0;
+ p->cutlen = 0;
}
static inline uint32_t
-dp_packet_set_cutlen(struct dp_packet *b, uint32_t max_len)
+dp_packet_set_cutlen(struct dp_packet *p, uint32_t max_len)
{
if (max_len < ETH_HEADER_LEN) {
max_len = ETH_HEADER_LEN;
}
- if (max_len >= dp_packet_size(b)) {
- b->cutlen = 0;
+ if (max_len >= dp_packet_size(p)) {
+ p->cutlen = 0;
} else {
- b->cutlen = dp_packet_size(b) - max_len;
+ p->cutlen = dp_packet_size(p) - max_len;
}
- return b->cutlen;
+ return p->cutlen;
}
static inline uint32_t
-dp_packet_get_cutlen(const struct dp_packet *b)
+dp_packet_get_cutlen(const struct dp_packet *p)
{
/* Always in valid range if user uses dp_packet_set_cutlen. */
- return b->cutlen;
+ return p->cutlen;
}
static inline uint32_t
-dp_packet_get_send_len(const struct dp_packet *b)
+dp_packet_get_send_len(const struct dp_packet *p)
{
- return dp_packet_size(b) - dp_packet_get_cutlen(b);
+ return dp_packet_size(p) - dp_packet_get_cutlen(p);
}
static inline void *
-dp_packet_data(const struct dp_packet *b)
+dp_packet_data(const struct dp_packet *p)
{
- return __packet_data(b) != UINT16_MAX
- ? (char *) dp_packet_base(b) + __packet_data(b) : NULL;
+ return __packet_data(p) != UINT16_MAX
+ ? (char *) dp_packet_base(p) + __packet_data(p) : NULL;
}
static inline void
-dp_packet_set_data(struct dp_packet *b, void *data)
+dp_packet_set_data(struct dp_packet *p, void *data)
{
if (data) {
- __packet_set_data(b, (char *) data - (char *) dp_packet_base(b));
+ __packet_set_data(p, (char *) data - (char *) dp_packet_base(p));
} else {
- __packet_set_data(b, UINT16_MAX);
+ __packet_set_data(p, UINT16_MAX);
}
}
static inline void
-dp_packet_reset_packet(struct dp_packet *b, int off)
+dp_packet_reset_packet(struct dp_packet *p, int off)
{
- dp_packet_set_size(b, dp_packet_size(b) - off);
- dp_packet_set_data(b, ((unsigned char *) dp_packet_data(b) + off));
- dp_packet_reset_offsets(b);
+ dp_packet_set_size(p, dp_packet_size(p) - off);
+ dp_packet_set_data(p, ((unsigned char *) dp_packet_data(p) + off));
+ dp_packet_reset_offsets(p);
}
enum { NETDEV_MAX_BURST = 32 }; /* Maximum number packets in a batch. */
@@ -757,69 +757,69 @@ struct dp_packet_batch {
};
static inline void
-dp_packet_batch_init(struct dp_packet_batch *batch)
+dp_packet_batch_init(struct dp_packet_batch *b)
{
- batch->count = 0;
- batch->trunc = false;
+ b->count = 0;
+ b->trunc = false;
}
static inline void
-dp_packet_batch_add__(struct dp_packet_batch *batch,
- struct dp_packet *packet, size_t limit)
+dp_packet_batch_add__(struct dp_packet_batch *b,
+ struct dp_packet *p, size_t limit)
{
- if (batch->count < limit) {
- batch->packets[batch->count++] = packet;
+ if (b->count < limit) {
+ b->packets[b->count++] = p;
} else {
- dp_packet_delete(packet);
+ dp_packet_delete(p);
}
}
-/* When the batch is full, 'packet' will be dropped and freed. */
+/* When the batch is full, 'p' will be dropped and freed. */
static inline void
-dp_packet_batch_add(struct dp_packet_batch *batch, struct dp_packet *packet)
+dp_packet_batch_add(struct dp_packet_batch *b, struct dp_packet *p)
{
- dp_packet_batch_add__(batch, packet, NETDEV_MAX_BURST);
+ dp_packet_batch_add__(b, p, NETDEV_MAX_BURST);
}
static inline size_t
-dp_packet_batch_size(const struct dp_packet_batch *batch)
+dp_packet_batch_size(const struct dp_packet_batch *b)
{
- return batch->count;
+ return b->count;
}
-/* Clear 'batch' for refill. Use dp_packet_batch_refill() to add
- * packets back into the 'batch'. */
+/* Clear 'b' for refill. Use dp_packet_batch_refill() to add
+ * packets back into the 'b'. */
static inline void
-dp_packet_batch_refill_init(struct dp_packet_batch *batch)
+dp_packet_batch_refill_init(struct dp_packet_batch *b)
{
- batch->count = 0;
+ b->count = 0;
};
static inline void
-dp_packet_batch_refill(struct dp_packet_batch *batch,
+dp_packet_batch_refill(struct dp_packet_batch *b,
struct dp_packet *packet, size_t idx)
{
- dp_packet_batch_add__(batch, packet, MIN(NETDEV_MAX_BURST, idx + 1));
+ dp_packet_batch_add__(b, packet, MIN(NETDEV_MAX_BURST, idx + 1));
}
static inline void
-dp_packet_batch_init_packet(struct dp_packet_batch *batch, struct dp_packet *p)
+dp_packet_batch_init_packet(struct dp_packet_batch *b, struct dp_packet *p)
{
- dp_packet_batch_init(batch);
- batch->count = 1;
- batch->packets[0] = p;
+ dp_packet_batch_init(b);
+ b->count = 1;
+ b->packets[0] = p;
}
static inline bool
-dp_packet_batch_is_empty(const struct dp_packet_batch *batch)
+dp_packet_batch_is_empty(const struct dp_packet_batch *b)
{
- return !dp_packet_batch_size(batch);
+ return !dp_packet_batch_size(b);
}
static inline bool
-dp_packet_batch_is_full(const struct dp_packet_batch *batch)
+dp_packet_batch_is_full(const struct dp_packet_batch *b)
{
- return dp_packet_batch_size(batch) == NETDEV_MAX_BURST;
+ return dp_packet_batch_size(b) == NETDEV_MAX_BURST;
}
#define DP_PACKET_BATCH_FOR_EACH(IDX, PACKET, BATCH) \
@@ -863,53 +863,53 @@ dp_packet_batch_clone(struct dp_packet_batch *dst,
}
static inline void
-dp_packet_delete_batch(struct dp_packet_batch *batch, bool should_steal)
+dp_packet_delete_batch(struct dp_packet_batch *b, bool should_steal)
{
if (should_steal) {
struct dp_packet *packet;
- DP_PACKET_BATCH_FOR_EACH (i, packet, batch) {
+ DP_PACKET_BATCH_FOR_EACH (i, packet, b) {
dp_packet_delete(packet);
}
- dp_packet_batch_init(batch);
+ dp_packet_batch_init(b);
}
}
static inline void
-dp_packet_batch_init_packet_fields(struct dp_packet_batch *batch)
+dp_packet_batch_init_packet_fields(struct dp_packet_batch *b)
{
struct dp_packet *packet;
- DP_PACKET_BATCH_FOR_EACH (i, packet, batch) {
+ DP_PACKET_BATCH_FOR_EACH (i, packet, b) {
dp_packet_reset_cutlen(packet);
packet->packet_type = htonl(PT_ETH);
}
}
static inline void
-dp_packet_batch_apply_cutlen(struct dp_packet_batch *batch)
+dp_packet_batch_apply_cutlen(struct dp_packet_batch *b)
{
- if (batch->trunc) {
+ if (b->trunc) {
struct dp_packet *packet;
- DP_PACKET_BATCH_FOR_EACH (i, packet, batch) {
+ DP_PACKET_BATCH_FOR_EACH (i, packet, b) {
dp_packet_set_size(packet, dp_packet_get_send_len(packet));
dp_packet_reset_cutlen(packet);
}
- batch->trunc = false;
+ b->trunc = false;
}
}
static inline void
-dp_packet_batch_reset_cutlen(struct dp_packet_batch *batch)
+dp_packet_batch_reset_cutlen(struct dp_packet_batch *b)
{
- if (batch->trunc) {
+ if (b->trunc) {
struct dp_packet *packet;
- DP_PACKET_BATCH_FOR_EACH (i, packet, batch) {
+ DP_PACKET_BATCH_FOR_EACH (i, packet, b) {
dp_packet_reset_cutlen(packet);
}
- batch->trunc = false;
+ b->trunc = false;
}
}
@@ -960,101 +960,101 @@ dp_packet_set_flow_mark(struct dp_packet *p, uint32_t mark)
/* Returns the L4 cksum offload bitmask. */
static inline uint64_t
-dp_packet_ol_l4_mask(const struct dp_packet *b)
+dp_packet_ol_l4_mask(const struct dp_packet *a)
{
- return *dp_packet_ol_flags_ptr(b) & DP_PACKET_OL_TX_L4_MASK;
+ return *dp_packet_ol_flags_ptr(a) & DP_PACKET_OL_TX_L4_MASK;
}
-/* Return true if the packet 'b' requested L4 checksum offload. */
+/* Return true if the packet 'a' requested L4 checksum offload. */
static inline bool
-dp_packet_ol_tx_l4_checksum(const struct dp_packet *b)
+dp_packet_ol_tx_l4_checksum(const struct dp_packet *a)
{
- return !!dp_packet_ol_l4_mask(b);
+ return !!dp_packet_ol_l4_mask(a);
}
-/* Returns 'true' if packet 'b' is marked for TCP segmentation offloading. */
+/* Returns 'true' if packet 'a' is marked for TCP segmentation offloading. */
static inline bool
-dp_packet_ol_is_tso(const struct dp_packet *b)
+dp_packet_ol_is_tso(const struct dp_packet *a)
{
- return !!(*dp_packet_ol_flags_ptr(b) & DP_PACKET_OL_TX_TCP_SEG);
+ return !!(*dp_packet_ol_flags_ptr(a) & DP_PACKET_OL_TX_TCP_SEG);
}
-/* Returns 'true' if packet 'b' is marked for IPv4 checksum offloading. */
+/* Returns 'true' if packet 'a' is marked for IPv4 checksum offloading. */
static inline bool
-dp_packet_ol_is_ipv4(const struct dp_packet *b)
+dp_packet_ol_is_ipv4(const struct dp_packet *a)
{
- return !!(*dp_packet_ol_flags_ptr(b) & DP_PACKET_OL_TX_IPV4);
+ return !!(*dp_packet_ol_flags_ptr(a) & DP_PACKET_OL_TX_IPV4);
}
-/* Returns 'true' if packet 'b' is marked for TCP checksum offloading. */
+/* Returns 'true' if packet 'a' is marked for TCP checksum offloading. */
static inline bool
-dp_packet_ol_l4_is_tcp(const struct dp_packet *b)
+dp_packet_ol_l4_is_tcp(const struct dp_packet *a)
{
- return (*dp_packet_ol_flags_ptr(b) & DP_PACKET_OL_TX_L4_MASK) ==
+ return (*dp_packet_ol_flags_ptr(a) & DP_PACKET_OL_TX_L4_MASK) ==
DP_PACKET_OL_TX_TCP_CSUM;
}
-/* Returns 'true' if packet 'b' is marked for UDP checksum offloading. */
+/* Returns 'true' if packet 'a' is marked for UDP checksum offloading. */
static inline bool
-dp_packet_ol_l4_is_udp(struct dp_packet *b)
+dp_packet_ol_l4_is_udp(struct dp_packet *a)
{
- return (*dp_packet_ol_flags_ptr(b) & DP_PACKET_OL_TX_L4_MASK) ==
+ return (*dp_packet_ol_flags_ptr(a) & DP_PACKET_OL_TX_L4_MASK) ==
DP_PACKET_OL_TX_UDP_CSUM;
}
-/* Returns 'true' if packet 'b' is marked for SCTP checksum offloading. */
+/* Returns 'true' if packet 'a' is marked for SCTP checksum offloading. */
static inline bool
-dp_packet_ol_l4_is_sctp(struct dp_packet *b)
+dp_packet_ol_l4_is_sctp(struct dp_packet *a)
{
- return (*dp_packet_ol_flags_ptr(b) & DP_PACKET_OL_TX_L4_MASK) ==
+ return (*dp_packet_ol_flags_ptr(a) & DP_PACKET_OL_TX_L4_MASK) ==
DP_PACKET_OL_TX_SCTP_CSUM;
}
-/* Mark packet 'b' for IPv4 checksum offloading. */
+/* Mark packet 'a' for IPv4 checksum offloading. */
static inline void
-dp_packet_ol_set_tx_ipv4(struct dp_packet *b)
+dp_packet_ol_set_tx_ipv4(struct dp_packet *a)
{
- *dp_packet_ol_flags_ptr(b) |= DP_PACKET_OL_TX_IPV4;
+ *dp_packet_ol_flags_ptr(a) |= DP_PACKET_OL_TX_IPV4;
}
-/* Mark packet 'b' for IPv6 checksum offloading. */
+/* Mark packet 'a' for IPv6 checksum offloading. */
static inline void
-dp_packet_ol_set_tx_ipv6(struct dp_packet *b)
+dp_packet_ol_set_tx_ipv6(struct dp_packet *a)
{
- *dp_packet_ol_flags_ptr(b) |= DP_PACKET_OL_TX_IPV6;
+ *dp_packet_ol_flags_ptr(a) |= DP_PACKET_OL_TX_IPV6;
}
-/* Mark packet 'b' for TCP checksum offloading. It implies that either
- * the packet 'b' is marked for IPv4 or IPv6 checksum offloading. */
+/* Mark packet 'a' for TCP checksum offloading. It implies that either
+ * the packet 'a' is marked for IPv4 or IPv6 checksum offloading. */
static inline void
-dp_packet_ol_set_csum_tcp(struct dp_packet *b)
+dp_packet_ol_set_csum_tcp(struct dp_packet *a)
{
- *dp_packet_ol_flags_ptr(b) |= DP_PACKET_OL_TX_TCP_CSUM;
+ *dp_packet_ol_flags_ptr(a) |= DP_PACKET_OL_TX_TCP_CSUM;
}
-/* Mark packet 'b' for UDP checksum offloading. It implies that either
- * the packet 'b' is marked for IPv4 or IPv6 checksum offloading. */
+/* Mark packet 'a' for UDP checksum offloading. It implies that either
+ * the packet 'a' is marked for IPv4 or IPv6 checksum offloading. */
static inline void
-dp_packet_ol_set_csum_udp(struct dp_packet *b)
+dp_packet_ol_set_csum_udp(struct dp_packet *a)
{
- *dp_packet_ol_flags_ptr(b) |= DP_PACKET_OL_TX_UDP_CSUM;
+ *dp_packet_ol_flags_ptr(a) |= DP_PACKET_OL_TX_UDP_CSUM;
}
-/* Mark packet 'b' for SCTP checksum offloading. It implies that either
- * the packet 'b' is marked for IPv4 or IPv6 checksum offloading. */
+/* Mark packet 'a' for SCTP checksum offloading. It implies that either
+ * the packet 'a' is marked for IPv4 or IPv6 checksum offloading. */
static inline void
-dp_packet_ol_set_csum_sctp(struct dp_packet *b)
+dp_packet_ol_set_csum_sctp(struct dp_packet *a)
{
- *dp_packet_ol_flags_ptr(b) |= DP_PACKET_OL_TX_SCTP_CSUM;
+ *dp_packet_ol_flags_ptr(a) |= DP_PACKET_OL_TX_SCTP_CSUM;
}
-/* Mark packet 'b' for TCP segmentation offloading. It implies that
- * either the packet 'b' is marked for IPv4 or IPv6 checksum offloading
+/* Mark packet 'a' for TCP segmentation offloading. It implies that
+ * either the packet 'a' is marked for IPv4 or IPv6 checksum offloading
* and also for TCP checksum offloading. */
static inline void
-dp_packet_ol_set_tcp_seg(struct dp_packet *b)
+dp_packet_ol_set_tcp_seg(struct dp_packet *a)
{
- *dp_packet_ol_flags_ptr(b) |= DP_PACKET_OL_TX_TCP_SEG;
+ *dp_packet_ol_flags_ptr(a) |= DP_PACKET_OL_TX_TCP_SEG;
}
static inline bool
@@ -224,14 +224,14 @@ static void
dummy_packet_stream_send(struct dummy_packet_stream *s, const void *buffer, size_t size)
{
if (ovs_list_size(&s->txq) < NETDEV_DUMMY_MAX_QUEUE) {
- struct dp_packet *b;
+ struct dp_packet *p;
struct pkt_list_node *node;
- b = dp_packet_clone_data_with_headroom(buffer, size, 2);
- put_unaligned_be16(dp_packet_push_uninit(b, 2), htons(size));
+ p = dp_packet_clone_data_with_headroom(buffer, size, 2);
+ put_unaligned_be16(dp_packet_push_uninit(p, 2), htons(size));
node = xmalloc(sizeof *node);
- node->pkt = b;
+ node->pkt = p;
ovs_list_push_back(&s->txq, &node->list_node);
}
}
@@ -522,8 +522,8 @@ static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(5, 20);
* changes in the device miimon status, so we can use atomic_count. */
static atomic_count miimon_cnt = ATOMIC_COUNT_INIT(0);
-static int netdev_linux_parse_vnet_hdr(struct dp_packet *b);
-static void netdev_linux_prepend_vnet_hdr(struct dp_packet *b, int mtu);
+static int netdev_linux_parse_vnet_hdr(struct dp_packet *p);
+static void netdev_linux_prepend_vnet_hdr(struct dp_packet *p, int mtu);
static int netdev_linux_do_ethtool(const char *name, struct ethtool_cmd *,
int cmd, const char *cmd_name);
static int get_flags(const struct netdev *, unsigned int *flags);
@@ -6586,13 +6586,13 @@ af_packet_sock(void)
}
static int
-netdev_linux_parse_l2(struct dp_packet *b, uint16_t *l4proto)
+netdev_linux_parse_l2(struct dp_packet *p, uint16_t *l4proto)
{
struct eth_header *eth_hdr;
ovs_be16 eth_type;
int l2_len;
- eth_hdr = dp_packet_at(b, 0, ETH_HEADER_LEN);
+ eth_hdr = dp_packet_at(p, 0, ETH_HEADER_LEN);
if (!eth_hdr) {
return -EINVAL;
}
@@ -6600,7 +6600,7 @@ netdev_linux_parse_l2(struct dp_packet *b, uint16_t *l4proto)
l2_len = ETH_HEADER_LEN;
eth_type = eth_hdr->eth_type;
if (eth_type_vlan(eth_type)) {
- struct vlan_header *vlan = dp_packet_at(b, l2_len, VLAN_HEADER_LEN);
+ struct vlan_header *vlan = dp_packet_at(p, l2_len, VLAN_HEADER_LEN);
if (!vlan) {
return -EINVAL;
@@ -6611,33 +6611,33 @@ netdev_linux_parse_l2(struct dp_packet *b, uint16_t *l4proto)
}
if (eth_type == htons(ETH_TYPE_IP)) {
- struct ip_header *ip_hdr = dp_packet_at(b, l2_len, IP_HEADER_LEN);
+ struct ip_header *ip_hdr = dp_packet_at(p, l2_len, IP_HEADER_LEN);
if (!ip_hdr) {
return -EINVAL;
}
*l4proto = ip_hdr->ip_proto;
- dp_packet_ol_set_tx_ipv4(b);
+ dp_packet_ol_set_tx_ipv4(p);
} else if (eth_type == htons(ETH_TYPE_IPV6)) {
struct ovs_16aligned_ip6_hdr *nh6;
- nh6 = dp_packet_at(b, l2_len, IPV6_HEADER_LEN);
+ nh6 = dp_packet_at(p, l2_len, IPV6_HEADER_LEN);
if (!nh6) {
return -EINVAL;
}
*l4proto = nh6->ip6_ctlun.ip6_un1.ip6_un1_nxt;
- dp_packet_ol_set_tx_ipv6(b);
+ dp_packet_ol_set_tx_ipv6(p);
}
return 0;
}
static int
-netdev_linux_parse_vnet_hdr(struct dp_packet *b)
+netdev_linux_parse_vnet_hdr(struct dp_packet *p)
{
- struct virtio_net_hdr *vnet = dp_packet_pull(b, sizeof *vnet);
+ struct virtio_net_hdr *vnet = dp_packet_pull(p, sizeof *vnet);
uint16_t l4proto = 0;
if (OVS_UNLIKELY(!vnet)) {
@@ -6648,17 +6648,17 @@ netdev_linux_parse_vnet_hdr(struct dp_packet *b)
return 0;
}
- if (netdev_linux_parse_l2(b, &l4proto)) {
+ if (netdev_linux_parse_l2(p, &l4proto)) {
return -EINVAL;
}
if (vnet->flags == VIRTIO_NET_HDR_F_NEEDS_CSUM) {
if (l4proto == IPPROTO_TCP) {
- dp_packet_ol_set_csum_tcp(b);
+ dp_packet_ol_set_csum_tcp(p);
} else if (l4proto == IPPROTO_UDP) {
- dp_packet_ol_set_csum_udp(b);
+ dp_packet_ol_set_csum_udp(p);
} else if (l4proto == IPPROTO_SCTP) {
- dp_packet_ol_set_csum_sctp(b);
+ dp_packet_ol_set_csum_sctp(p);
}
}
@@ -6670,7 +6670,7 @@ netdev_linux_parse_vnet_hdr(struct dp_packet *b)
if (type == VIRTIO_NET_HDR_GSO_TCPV4
|| type == VIRTIO_NET_HDR_GSO_TCPV6) {
- dp_packet_ol_set_tcp_seg(b);
+ dp_packet_ol_set_tcp_seg(p);
}
}
@@ -6678,17 +6678,17 @@ netdev_linux_parse_vnet_hdr(struct dp_packet *b)
}
static void
-netdev_linux_prepend_vnet_hdr(struct dp_packet *b, int mtu)
+netdev_linux_prepend_vnet_hdr(struct dp_packet *p, int mtu)
{
- struct virtio_net_hdr *vnet = dp_packet_push_zeros(b, sizeof *vnet);
+ struct virtio_net_hdr *vnet = dp_packet_push_zeros(p, sizeof *vnet);
- if (dp_packet_ol_is_tso(b)) {
- uint16_t hdr_len = ((char *)dp_packet_l4(b) - (char *)dp_packet_eth(b))
- + TCP_HEADER_LEN;
+ if (dp_packet_ol_is_tso(p)) {
+ uint16_t hdr_len = ((char *) dp_packet_l4(p)
+ - (char *) dp_packet_eth(p)) + TCP_HEADER_LEN;
vnet->hdr_len = (OVS_FORCE __virtio16)hdr_len;
vnet->gso_size = (OVS_FORCE __virtio16)(mtu - hdr_len);
- if (dp_packet_ol_is_ipv4(b)) {
+ if (dp_packet_ol_is_ipv4(p)) {
vnet->gso_type = VIRTIO_NET_HDR_GSO_TCPV4;
} else {
vnet->gso_type = VIRTIO_NET_HDR_GSO_TCPV6;
@@ -6698,18 +6698,18 @@ netdev_linux_prepend_vnet_hdr(struct dp_packet *b, int mtu)
vnet->flags = VIRTIO_NET_HDR_GSO_NONE;
}
- if (dp_packet_ol_l4_mask(b)) {
+ if (dp_packet_ol_l4_mask(p)) {
vnet->flags = VIRTIO_NET_HDR_F_NEEDS_CSUM;
- vnet->csum_start = (OVS_FORCE __virtio16)((char *)dp_packet_l4(b)
- - (char *)dp_packet_eth(b));
+ vnet->csum_start = (OVS_FORCE __virtio16)((char *) dp_packet_l4(p)
+ - (char *) dp_packet_eth(p));
- if (dp_packet_ol_l4_is_tcp(b)) {
+ if (dp_packet_ol_l4_is_tcp(p)) {
vnet->csum_offset = (OVS_FORCE __virtio16) __builtin_offsetof(
struct tcp_header, tcp_csum);
- } else if (dp_packet_ol_l4_is_udp(b)) {
+ } else if (dp_packet_ol_l4_is_udp(p)) {
vnet->csum_offset = (OVS_FORCE __virtio16) __builtin_offsetof(
struct udp_header, udp_csum);
- } else if (dp_packet_ol_l4_is_sctp(b)) {
+ } else if (dp_packet_ol_l4_is_sctp(p)) {
vnet->csum_offset = (OVS_FORCE __virtio16) __builtin_offsetof(
struct sctp_header, sctp_csum);
} else {
@@ -192,28 +192,28 @@ eth_addr_from_string(const char *s, struct eth_addr *ea)
}
}
-/* Fills 'b' with a Reverse ARP packet with Ethernet source address 'eth_src'.
+/* Fills 'p' with a Reverse ARP packet with Ethernet source address 'eth_src'.
* This function is used by Open vSwitch to compose packets in cases where
* context is important but content doesn't (or shouldn't) matter.
*
* The returned packet has enough headroom to insert an 802.1Q VLAN header if
* desired. */
void
-compose_rarp(struct dp_packet *b, const struct eth_addr eth_src)
+compose_rarp(struct dp_packet *p, const struct eth_addr eth_src)
{
struct eth_header *eth;
struct arp_eth_header *arp;
- dp_packet_clear(b);
- dp_packet_prealloc_tailroom(b, 2 + ETH_HEADER_LEN + VLAN_HEADER_LEN
+ dp_packet_clear(p);
+ dp_packet_prealloc_tailroom(p, 2 + ETH_HEADER_LEN + VLAN_HEADER_LEN
+ ARP_ETH_HEADER_LEN);
- dp_packet_reserve(b, 2 + VLAN_HEADER_LEN);
- eth = dp_packet_put_uninit(b, sizeof *eth);
+ dp_packet_reserve(p, 2 + VLAN_HEADER_LEN);
+ eth = dp_packet_put_uninit(p, sizeof *eth);
eth->eth_dst = eth_addr_broadcast;
eth->eth_src = eth_src;
eth->eth_type = htons(ETH_TYPE_RARP);
- arp = dp_packet_put_uninit(b, sizeof *arp);
+ arp = dp_packet_put_uninit(p, sizeof *arp);
arp->ar_hrd = htons(ARP_HRD_ETHERNET);
arp->ar_pro = htons(ARP_PRO_IP);
arp->ar_hln = sizeof arp->ar_sha;
@@ -224,9 +224,9 @@ compose_rarp(struct dp_packet *b, const struct eth_addr eth_src)
arp->ar_tha = eth_src;
put_16aligned_be32(&arp->ar_tpa, htonl(0));
- dp_packet_reset_offsets(b);
- dp_packet_set_l3(b, arp);
- b->packet_type = htonl(PT_ETH);
+ dp_packet_reset_offsets(p);
+ dp_packet_set_l3(p, arp);
+ p->packet_type = htonl(PT_ETH);
}
/* Insert VLAN header according to given TCI. Packet passed must be Ethernet
@@ -1082,17 +1082,17 @@ ipv6_is_cidr(const struct in6_addr *netmask)
return true;
}
-/* Populates 'b' with an Ethernet II packet headed with the given 'eth_dst',
+/* Populates 'p' with an Ethernet II packet headed with the given 'eth_dst',
* 'eth_src' and 'eth_type' parameters. A payload of 'size' bytes is allocated
- * in 'b' and returned. This payload may be populated with appropriate
- * information by the caller. Sets 'b''s 'frame' pointer and 'l3' offset to
+ * in 'p' and returned. This payload may be populated with appropriate
+ * information by the caller. Sets 'p''s 'frame' pointer and 'l3' offset to
* the Ethernet header and payload respectively. Aligns b->l3 on a 32-bit
* boundary.
*
* The returned packet has enough headroom to insert an 802.1Q VLAN header if
* desired. */
void *
-eth_compose(struct dp_packet *b, const struct eth_addr eth_dst,
+eth_compose(struct dp_packet *p, const struct eth_addr eth_dst,
const struct eth_addr eth_src, uint16_t eth_type,
size_t size)
{
@@ -1100,22 +1100,22 @@ eth_compose(struct dp_packet *b, const struct eth_addr eth_dst,
struct eth_header *eth;
- dp_packet_clear(b);
+ dp_packet_clear(p);
/* The magic 2 here ensures that the L3 header (when it is added later)
* will be 32-bit aligned. */
- dp_packet_prealloc_tailroom(b, 2 + ETH_HEADER_LEN + VLAN_HEADER_LEN + size);
- dp_packet_reserve(b, 2 + VLAN_HEADER_LEN);
- eth = dp_packet_put_uninit(b, ETH_HEADER_LEN);
- data = dp_packet_put_zeros(b, size);
+ dp_packet_prealloc_tailroom(p, 2 + ETH_HEADER_LEN + VLAN_HEADER_LEN + size);
+ dp_packet_reserve(p, 2 + VLAN_HEADER_LEN);
+ eth = dp_packet_put_uninit(p, ETH_HEADER_LEN);
+ data = dp_packet_put_zeros(p, size);
eth->eth_dst = eth_dst;
eth->eth_src = eth_src;
eth->eth_type = htons(eth_type);
- b->packet_type = htonl(PT_ETH);
- dp_packet_reset_offsets(b);
- dp_packet_set_l3(b, data);
+ p->packet_type = htonl(PT_ETH);
+ dp_packet_reset_offsets(p);
+ dp_packet_set_l3(p, data);
return data;
}
@@ -1648,23 +1648,23 @@ packet_format_tcp_flags(struct ds *s, uint16_t tcp_flags)
#define ARP_PACKET_SIZE (2 + ETH_HEADER_LEN + VLAN_HEADER_LEN + \
ARP_ETH_HEADER_LEN)
-/* Clears 'b' and replaces its contents by an ARP frame with the specified
+/* Clears 'p' and replaces its contents by an ARP frame with the specified
* 'arp_op', 'arp_sha', 'arp_tha', 'arp_spa', and 'arp_tpa'. The outer
* Ethernet frame is initialized with Ethernet source 'arp_sha' and destination
* 'arp_tha', except that destination ff:ff:ff:ff:ff:ff is used instead if
* 'broadcast' is true. Points the L3 header to the ARP header. */
void
-compose_arp(struct dp_packet *b, uint16_t arp_op,
+compose_arp(struct dp_packet *p, uint16_t arp_op,
const struct eth_addr arp_sha, const struct eth_addr arp_tha,
bool broadcast, ovs_be32 arp_spa, ovs_be32 arp_tpa)
{
- compose_arp__(b);
+ compose_arp__(p);
- struct eth_header *eth = dp_packet_eth(b);
+ struct eth_header *eth = dp_packet_eth(p);
eth->eth_dst = broadcast ? eth_addr_broadcast : arp_tha;
eth->eth_src = arp_sha;
- struct arp_eth_header *arp = dp_packet_l3(b);
+ struct arp_eth_header *arp = dp_packet_l3(p);
arp->ar_op = htons(arp_op);
arp->ar_sha = arp_sha;
arp->ar_tha = arp_tha;
@@ -1672,30 +1672,30 @@ compose_arp(struct dp_packet *b, uint16_t arp_op,
put_16aligned_be32(&arp->ar_tpa, arp_tpa);
}
-/* Clears 'b' and replaces its contents by an ARP frame. Sets the fields in
+/* Clears 'p' and replaces its contents by an ARP frame. Sets the fields in
* the Ethernet and ARP headers that are fixed for ARP frames to those fixed
* values, and zeroes the other fields. Points the L3 header to the ARP
* header. */
void
-compose_arp__(struct dp_packet *b)
+compose_arp__(struct dp_packet *p)
{
- dp_packet_clear(b);
- dp_packet_prealloc_tailroom(b, ARP_PACKET_SIZE);
- dp_packet_reserve(b, 2 + VLAN_HEADER_LEN);
+ dp_packet_clear(p);
+ dp_packet_prealloc_tailroom(p, ARP_PACKET_SIZE);
+ dp_packet_reserve(p, 2 + VLAN_HEADER_LEN);
- struct eth_header *eth = dp_packet_put_zeros(b, sizeof *eth);
+ struct eth_header *eth = dp_packet_put_zeros(p, sizeof *eth);
eth->eth_type = htons(ETH_TYPE_ARP);
- struct arp_eth_header *arp = dp_packet_put_zeros(b, sizeof *arp);
+ struct arp_eth_header *arp = dp_packet_put_zeros(p, sizeof *arp);
arp->ar_hrd = htons(ARP_HRD_ETHERNET);
arp->ar_pro = htons(ARP_PRO_IP);
arp->ar_hln = sizeof arp->ar_sha;
arp->ar_pln = sizeof arp->ar_spa;
- dp_packet_reset_offsets(b);
- dp_packet_set_l3(b, arp);
+ dp_packet_reset_offsets(p);
+ dp_packet_set_l3(p, arp);
- b->packet_type = htonl(PT_ETH);
+ p->packet_type = htonl(PT_ETH);
}
/* This function expects packet with ethernet header with correct
@@ -1720,7 +1720,7 @@ compose_ipv6(struct dp_packet *packet, uint8_t proto,
/* Compose an IPv6 Neighbor Discovery Neighbor Solicitation message. */
void
-compose_nd_ns(struct dp_packet *b, const struct eth_addr eth_src,
+compose_nd_ns(struct dp_packet *p, const struct eth_addr eth_src,
const struct in6_addr *ipv6_src, const struct in6_addr *ipv6_dst)
{
struct in6_addr sn_addr;
@@ -1732,8 +1732,8 @@ compose_nd_ns(struct dp_packet *b, const struct eth_addr eth_src,
in6_addr_solicited_node(&sn_addr, ipv6_dst);
ipv6_multicast_to_ethernet(ð_dst, &sn_addr);
- eth_compose(b, eth_dst, eth_src, ETH_TYPE_IPV6, IPV6_HEADER_LEN);
- ns = compose_ipv6(b, IPPROTO_ICMPV6, ipv6_src, &sn_addr,
+ eth_compose(p, eth_dst, eth_src, ETH_TYPE_IPV6, IPV6_HEADER_LEN);
+ ns = compose_ipv6(p, IPPROTO_ICMPV6, ipv6_src, &sn_addr,
0, 0, 255, ND_MSG_LEN + ND_LLA_OPT_LEN);
ns->icmph.icmp6_type = ND_NEIGHBOR_SOLICIT;
@@ -1744,17 +1744,17 @@ compose_nd_ns(struct dp_packet *b, const struct eth_addr eth_src,
lla_opt->type = ND_OPT_SOURCE_LINKADDR;
lla_opt->len = 1;
- packet_set_nd(b, ipv6_dst, eth_src, eth_addr_zero);
+ packet_set_nd(p, ipv6_dst, eth_src, eth_addr_zero);
ns->icmph.icmp6_cksum = 0;
- icmp_csum = packet_csum_pseudoheader6(dp_packet_l3(b));
+ icmp_csum = packet_csum_pseudoheader6(dp_packet_l3(p));
ns->icmph.icmp6_cksum = csum_finish(
csum_continue(icmp_csum, ns, ND_MSG_LEN + ND_LLA_OPT_LEN));
}
/* Compose an IPv6 Neighbor Discovery Neighbor Advertisement message. */
void
-compose_nd_na(struct dp_packet *b,
+compose_nd_na(struct dp_packet *p,
const struct eth_addr eth_src, const struct eth_addr eth_dst,
const struct in6_addr *ipv6_src, const struct in6_addr *ipv6_dst,
ovs_be32 rso_flags)
@@ -1763,8 +1763,8 @@ compose_nd_na(struct dp_packet *b,
struct ovs_nd_lla_opt *lla_opt;
uint32_t icmp_csum;
- eth_compose(b, eth_dst, eth_src, ETH_TYPE_IPV6, IPV6_HEADER_LEN);
- na = compose_ipv6(b, IPPROTO_ICMPV6, ipv6_src, ipv6_dst,
+ eth_compose(p, eth_dst, eth_src, ETH_TYPE_IPV6, IPV6_HEADER_LEN);
+ na = compose_ipv6(p, IPPROTO_ICMPV6, ipv6_src, ipv6_dst,
0, 0, 255, ND_MSG_LEN + ND_LLA_OPT_LEN);
na->icmph.icmp6_type = ND_NEIGHBOR_ADVERT;
@@ -1775,10 +1775,10 @@ compose_nd_na(struct dp_packet *b,
lla_opt->type = ND_OPT_TARGET_LINKADDR;
lla_opt->len = 1;
- packet_set_nd(b, ipv6_src, eth_addr_zero, eth_src);
+ packet_set_nd(p, ipv6_src, eth_addr_zero, eth_src);
na->icmph.icmp6_cksum = 0;
- icmp_csum = packet_csum_pseudoheader6(dp_packet_l3(b));
+ icmp_csum = packet_csum_pseudoheader6(dp_packet_l3(p));
na->icmph.icmp6_cksum = csum_finish(csum_continue(
icmp_csum, na, ND_MSG_LEN + ND_LLA_OPT_LEN));
}
@@ -1786,9 +1786,9 @@ compose_nd_na(struct dp_packet *b,
/* Compose an IPv6 Neighbor Discovery Router Advertisement message with
* Source Link-layer Address Option and MTU Option.
* Caller can call packet_put_ra_prefix_opt to append Prefix Information
- * Options to composed messags in 'b'. */
+ * Options to composed messags in 'p'. */
void
-compose_nd_ra(struct dp_packet *b,
+compose_nd_ra(struct dp_packet *p,
const struct eth_addr eth_src, const struct eth_addr eth_dst,
const struct in6_addr *ipv6_src, const struct in6_addr *ipv6_dst,
uint8_t cur_hop_limit, uint8_t mo_flags,
@@ -1800,10 +1800,10 @@ compose_nd_ra(struct dp_packet *b,
bool with_mtu = mtu != 0;
size_t mtu_opt_len = with_mtu ? ND_MTU_OPT_LEN : 0;
- eth_compose(b, eth_dst, eth_src, ETH_TYPE_IPV6, IPV6_HEADER_LEN);
+ eth_compose(p, eth_dst, eth_src, ETH_TYPE_IPV6, IPV6_HEADER_LEN);
struct ovs_ra_msg *ra = compose_ipv6(
- b, IPPROTO_ICMPV6, ipv6_src, ipv6_dst, 0, 0, 255,
+ p, IPPROTO_ICMPV6, ipv6_src, ipv6_dst, 0, 0, 255,
RA_MSG_LEN + ND_LLA_OPT_LEN + mtu_opt_len);
ra->icmph.icmp6_type = ND_ROUTER_ADVERT;
ra->icmph.icmp6_code = 0;
@@ -1829,7 +1829,7 @@ compose_nd_ra(struct dp_packet *b,
}
ra->icmph.icmp6_cksum = 0;
- uint32_t icmp_csum = packet_csum_pseudoheader6(dp_packet_l3(b));
+ uint32_t icmp_csum = packet_csum_pseudoheader6(dp_packet_l3(p));
ra->icmph.icmp6_cksum = csum_finish(csum_continue(
icmp_csum, ra, RA_MSG_LEN + ND_LLA_OPT_LEN + mtu_opt_len));
}
@@ -1837,17 +1837,17 @@ compose_nd_ra(struct dp_packet *b,
/* Append an IPv6 Neighbor Discovery Prefix Information option to a
* Router Advertisement message. */
void
-packet_put_ra_prefix_opt(struct dp_packet *b,
+packet_put_ra_prefix_opt(struct dp_packet *p,
uint8_t plen, uint8_t la_flags,
ovs_be32 valid_lifetime, ovs_be32 preferred_lifetime,
const ovs_be128 prefix)
{
- size_t prev_l4_size = dp_packet_l4_size(b);
- struct ip6_hdr *nh = dp_packet_l3(b);
+ size_t prev_l4_size = dp_packet_l4_size(p);
+ struct ip6_hdr *nh = dp_packet_l3(p);
nh->ip6_plen = htons(prev_l4_size + ND_PREFIX_OPT_LEN);
struct ovs_nd_prefix_opt *prefix_opt =
- dp_packet_put_uninit(b, sizeof *prefix_opt);
+ dp_packet_put_uninit(p, sizeof *prefix_opt);
prefix_opt->type = ND_OPT_PREFIX_INFORMATION;
prefix_opt->len = 4;
prefix_opt->prefix_len = plen;
@@ -1857,9 +1857,9 @@ packet_put_ra_prefix_opt(struct dp_packet *b,
put_16aligned_be32(&prefix_opt->reserved, 0);
memcpy(prefix_opt->prefix.be32, prefix.be32, sizeof(ovs_be32[4]));
- struct ovs_ra_msg *ra = dp_packet_l4(b);
+ struct ovs_ra_msg *ra = dp_packet_l4(p);
ra->icmph.icmp6_cksum = 0;
- uint32_t icmp_csum = packet_csum_pseudoheader6(dp_packet_l3(b));
+ uint32_t icmp_csum = packet_csum_pseudoheader6(dp_packet_l3(p));
ra->icmph.icmp6_cksum = csum_finish(csum_continue(
icmp_csum, ra, prev_l4_size + ND_PREFIX_OPT_LEN));
}