static struct ofport_dpif *get_ofp_port(const struct ofproto_dpif *ofproto,
ofp_port_t ofp_port);
static void ofproto_trace(struct ofproto_dpif *, struct flow *,
- const struct ofpbuf *packet,
+ const struct dp_packet *packet,
const struct ofpact[], size_t ofpacts_len,
struct ds *);
struct eth_header *eth;
struct ofpbuf actions;
struct dpif_execute execute;
- struct ofpbuf packet;
+ struct dp_packet packet;
size_t start;
int error;
nl_msg_end_nested(&actions, start);
/* Compose a dummy ethernet packet. */
- ofpbuf_init(&packet, ETH_HEADER_LEN);
- eth = ofpbuf_put_zeros(&packet, ETH_HEADER_LEN);
+ dp_packet_init(&packet, ETH_HEADER_LEN);
+ eth = dp_packet_put_zeros(&packet, ETH_HEADER_LEN);
eth->eth_type = htons(0x1234);
/* Execute the actions. On older datapaths this fails with ERANGE, on
execute.actions = ofpbuf_data(&actions);
execute.actions_len = ofpbuf_size(&actions);
execute.packet = &packet;
- execute.md = PKT_METADATA_INITIALIZER(0);
execute.needs_help = false;
execute.probe = true;
error = dpif_execute(backer->dpif, &execute);
- ofpbuf_uninit(&packet);
+ dp_packet_uninit(&packet);
ofpbuf_uninit(&actions);
switch (error) {
struct eth_header *eth;
struct ofpbuf actions;
struct dpif_execute execute;
- struct ofpbuf packet;
+ struct dp_packet packet;
int error;
struct ovs_key_ethernet key, mask;
sizeof key);
/* Compose a dummy ethernet packet. */
- ofpbuf_init(&packet, ETH_HEADER_LEN);
- eth = ofpbuf_put_zeros(&packet, ETH_HEADER_LEN);
+ dp_packet_init(&packet, ETH_HEADER_LEN);
+ eth = dp_packet_put_zeros(&packet, ETH_HEADER_LEN);
eth->eth_type = htons(0x1234);
/* Execute the actions. On older datapaths this fails with EINVAL, on
execute.actions = ofpbuf_data(&actions);
execute.actions_len = ofpbuf_size(&actions);
execute.packet = &packet;
- execute.md = PKT_METADATA_INITIALIZER(0);
execute.needs_help = false;
execute.probe = true;
error = dpif_execute(backer->dpif, &execute);
- ofpbuf_uninit(&packet);
+ dp_packet_uninit(&packet);
ofpbuf_uninit(&actions);
if (error) {
/* Called while rstp_mutex is held. */
static void
-rstp_send_bpdu_cb(struct ofpbuf *pkt, void *ofport_, void *ofproto_)
+rstp_send_bpdu_cb(struct dp_packet *pkt, void *ofport_, void *ofproto_)
{
struct ofproto_dpif *ofproto = ofproto_;
struct ofport_dpif *ofport = ofport_;
- struct eth_header *eth = ofpbuf_l2(pkt);
+ struct eth_header *eth = dp_packet_l2(pkt);
netdev_get_etheraddr(ofport->up.netdev, eth->eth_src);
if (eth_addr_is_zero(eth->eth_src)) {
} else {
ofproto_dpif_send_packet(ofport, pkt);
}
- ofpbuf_delete(pkt);
+ dp_packet_delete(pkt);
}
static void
-send_bpdu_cb(struct ofpbuf *pkt, int port_num, void *ofproto_)
+send_bpdu_cb(struct dp_packet *pkt, int port_num, void *ofproto_)
{
struct ofproto_dpif *ofproto = ofproto_;
struct stp_port *sp = stp_get_port(ofproto->stp, port_num);
VLOG_WARN_RL(&rl, "%s: cannot send BPDU on unknown port %d",
ofproto->up.name, port_num);
} else {
- struct eth_header *eth = ofpbuf_l2(pkt);
+ struct eth_header *eth = dp_packet_l2(pkt);
netdev_get_etheraddr(ofport->up.netdev, eth->eth_src);
if (eth_addr_is_zero(eth->eth_src)) {
ofproto_dpif_send_packet(ofport, pkt);
}
}
- ofpbuf_delete(pkt);
+ dp_packet_delete(pkt);
}
/* Configure RSTP on 'ofproto_' using the settings defined in 's'. */
error = netdev_get_etheraddr(port->up.netdev, ea);
if (!error) {
- struct ofpbuf packet;
+ struct dp_packet packet;
void *packet_pdu;
- ofpbuf_init(&packet, 0);
+ dp_packet_init(&packet, 0);
packet_pdu = eth_compose(&packet, eth_addr_lacp, ea, ETH_TYPE_LACP,
pdu_size);
memcpy(packet_pdu, pdu, pdu_size);
ofproto_dpif_send_packet(port, &packet);
- ofpbuf_uninit(&packet);
+ dp_packet_uninit(&packet);
} else {
VLOG_ERR_RL(&rl, "port %s: cannot obtain Ethernet address of iface "
"%s (%s)", port->bundle->name,
bundle_send_learning_packets(struct ofbundle *bundle)
{
struct ofproto_dpif *ofproto = bundle->ofproto;
- struct ofpbuf *learning_packet;
+ struct dp_packet *learning_packet;
int error, n_packets, n_errors;
struct mac_entry *e;
struct ovs_list packets;
e->mac, e->vlan,
&port_void);
/* Temporarily use 'frame' as a private pointer (see below). */
- ovs_assert(learning_packet->frame == ofpbuf_data(learning_packet));
+ ovs_assert(learning_packet->frame == dp_packet_data(learning_packet));
learning_packet->frame = port_void;
list_push_back(&packets, &learning_packet->list_node);
}
void *port_void = learning_packet->frame;
/* Restore 'frame'. */
- learning_packet->frame = ofpbuf_data(learning_packet);
+ learning_packet->frame = dp_packet_data(learning_packet);
ret = ofproto_dpif_send_packet(port_void, learning_packet);
if (ret) {
error = ret;
}
n_packets++;
}
- ofpbuf_list_delete(&packets);
+ dp_packet_list_delete(&packets);
if (n_errors) {
static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5);
const struct flow *flow,
struct rule_dpif *rule,
const struct ofpact *ofpacts, size_t ofpacts_len,
- struct ofpbuf *packet)
+ struct dp_packet *packet)
{
struct dpif_flow_stats stats;
struct xlate_out xout;
execute.actions = ofpbuf_data(xout.odp_actions);
execute.actions_len = ofpbuf_size(xout.odp_actions);
+ pkt_metadata_from_flow(&packet->md, flow);
execute.packet = packet;
- execute.md = pkt_metadata_from_flow(flow);
execute.needs_help = (xout.slow & SLOW_ACTION) != 0;
execute.probe = false;
if (in_port == OFPP_NONE) {
in_port = OFPP_LOCAL;
}
- execute.md.in_port.odp_port = ofp_port_to_odp_port(ofproto, in_port);
+ execute.packet->md.in_port.odp_port = ofp_port_to_odp_port(ofproto, in_port);
error = dpif_execute(ofproto->backer->dpif, &execute);
static void
rule_dpif_execute(struct rule_dpif *rule, const struct flow *flow,
- struct ofpbuf *packet)
+ struct dp_packet *packet)
{
struct ofproto_dpif *ofproto = ofproto_dpif_cast(rule->up.ofproto);
static enum ofperr
rule_execute(struct rule *rule, const struct flow *flow,
- struct ofpbuf *packet)
+ struct dp_packet *packet)
{
rule_dpif_execute(rule_dpif_cast(rule), flow, packet);
- ofpbuf_delete(packet);
+ dp_packet_delete(packet);
return 0;
}
* May modify 'packet'.
* Returns 0 if successful, otherwise a positive errno value. */
int
-ofproto_dpif_send_packet(const struct ofport_dpif *ofport, struct ofpbuf *packet)
+ofproto_dpif_send_packet(const struct ofport_dpif *ofport, struct dp_packet *packet)
{
struct ofproto_dpif *ofproto = ofproto_dpif_cast(ofport->up.ofproto);
int error;
ovs_mutex_lock(&ofproto->stats_mutex);
ofproto->stats.tx_packets++;
- ofproto->stats.tx_bytes += ofpbuf_size(packet);
+ ofproto->stats.tx_bytes += dp_packet_size(packet);
ovs_mutex_unlock(&ofproto->stats_mutex);
return error;
}
}
static enum ofperr
-packet_out(struct ofproto *ofproto_, struct ofpbuf *packet,
+packet_out(struct ofproto *ofproto_, struct dp_packet *packet,
const struct flow *flow,
const struct ofpact *ofpacts, size_t ofpacts_len)
{
static char * OVS_WARN_UNUSED_RESULT
parse_flow_and_packet(int argc, const char *argv[],
struct ofproto_dpif **ofprotop, struct flow *flow,
- struct ofpbuf **packetp)
+ struct dp_packet **packetp)
{
const struct dpif_backer *backer = NULL;
const char *error = NULL;
char *m_err = NULL;
struct simap port_names = SIMAP_INITIALIZER(&port_names);
- struct ofpbuf *packet;
+ struct dp_packet *packet;
struct ofpbuf odp_key;
struct ofpbuf odp_mask;
/* Handle "-generate" or a hex string as the last argument. */
if (!strcmp(argv[argc - 1], "-generate")) {
- packet = ofpbuf_new(0);
+ packet = dp_packet_new(0);
argc--;
} else {
error = eth_from_hex(argv[argc - 1], &packet);
/* Generate a packet, if requested. */
if (packet) {
- if (!ofpbuf_size(packet)) {
+ if (!dp_packet_size(packet)) {
flow_compose(packet, flow);
} else {
- struct pkt_metadata md = pkt_metadata_from_flow(flow);
-
/* Use the metadata from the flow and the packet argument
* to reconstruct the flow. */
- flow_extract(packet, &md, flow);
+ pkt_metadata_from_flow(&packet->md, flow);
+ flow_extract(packet, flow);
}
}
m_err = xstrdup(error);
}
if (m_err) {
- ofpbuf_delete(packet);
+ dp_packet_delete(packet);
packet = NULL;
}
*packetp = packet;
void *aux OVS_UNUSED)
{
struct ofproto_dpif *ofproto;
- struct ofpbuf *packet;
+ struct dp_packet *packet;
char *error;
struct flow flow;
ofproto_trace(ofproto, &flow, packet, NULL, 0, &result);
unixctl_command_reply(conn, ds_cstr(&result));
ds_destroy(&result);
- ofpbuf_delete(packet);
+ dp_packet_delete(packet);
} else {
unixctl_command_reply_error(conn, error);
free(error);
struct ofproto_dpif *ofproto;
bool enforce_consistency;
struct ofpbuf ofpacts;
- struct ofpbuf *packet;
+ struct dp_packet *packet;
struct ds result;
struct flow flow;
uint16_t in_port;
exit:
ds_destroy(&result);
- ofpbuf_delete(packet);
+ dp_packet_delete(packet);
ofpbuf_uninit(&ofpacts);
}
* trace, otherwise the actions are determined by a flow table lookup. */
static void
ofproto_trace(struct ofproto_dpif *ofproto, struct flow *flow,
- const struct ofpbuf *packet,
+ const struct dp_packet *packet,
const struct ofpact ofpacts[], size_t ofpacts_len,
struct ds *ds)
{
* changes. */
bool
vsp_adjust_flow(const struct ofproto_dpif *ofproto, struct flow *flow,
- struct ofpbuf *packet)
+ struct dp_packet *packet)
OVS_EXCLUDED(ofproto->vsp_mutex)
{
ofp_port_t realdev;