mirror of
https://github.com/openvswitch/ovs
synced 2025-08-31 14:25:26 +00:00
ofp-actions: Add truncate action.
The patch adds a new action to support packet truncation. The new action is formatted as 'output(port=n,max_len=m)', as output to port n, with packet size being MIN(original_size, m). One use case is to enable port mirroring to send smaller packets to the destination port so that only useful packet information is mirrored/copied, saving some performance overhead of copying entire packet payload. Example use case is below as well as shown in the testcases: - Output to port 1 with max_len 100 bytes. - The output packet size on port 1 will be MIN(original_packet_size, 100). # ovs-ofctl add-flow br0 'actions=output(port=1,max_len=100)' - The scope of max_len is limited to output action itself. The following packet size of output:1 and output:2 will be intact. # ovs-ofctl add-flow br0 \ 'actions=output(port=1,max_len=100),output:1,output:2' - The Datapath actions shows: # Datapath actions: trunc(100),1,1,2 Tested-at: https://travis-ci.org/williamtu/ovs-travis/builds/140037134 Signed-off-by: William Tu <u9012063@gmail.com> Acked-by: Pravin B Shelar <pshelar@ovn.org>
This commit is contained in:
committed by
Pravin B Shelar
parent
4c7804f14b
commit
aaca4fe0ce
@@ -1503,6 +1503,10 @@ dpdk_do_tx_copy(struct netdev *netdev, int qid, struct dp_packet **pkts,
|
||||
break;
|
||||
}
|
||||
|
||||
/* Cut the size so only the truncated size is copied. */
|
||||
size -= dp_packet_get_cutlen(pkts[i]);
|
||||
dp_packet_reset_cutlen(pkts[i]);
|
||||
|
||||
/* We have to do a copy for now */
|
||||
memcpy(rte_pktmbuf_mtod(mbufs[newcnt], void *), dp_packet_data(pkts[i]), size);
|
||||
|
||||
@@ -1550,6 +1554,14 @@ netdev_dpdk_vhost_send(struct netdev *netdev, int qid, struct dp_packet **pkts,
|
||||
}
|
||||
}
|
||||
} else {
|
||||
int i;
|
||||
|
||||
for (i = 0; i < cnt; i++) {
|
||||
int cutlen = dp_packet_get_cutlen(pkts[i]);
|
||||
|
||||
dp_packet_set_size(pkts[i], dp_packet_size(pkts[i]) - cutlen);
|
||||
dp_packet_reset_cutlen(pkts[i]);
|
||||
}
|
||||
__netdev_dpdk_vhost_send(netdev, qid, pkts, cnt, may_steal);
|
||||
}
|
||||
return 0;
|
||||
@@ -1586,6 +1598,9 @@ netdev_dpdk_send__(struct netdev_dpdk *dev, int qid,
|
||||
for (i = 0; i < cnt; i++) {
|
||||
int size = dp_packet_size(pkts[i]);
|
||||
|
||||
size -= dp_packet_get_cutlen(pkts[i]);
|
||||
dp_packet_set_size(pkts[i], size);
|
||||
|
||||
if (OVS_UNLIKELY(size > dev->max_packet_len)) {
|
||||
if (next_tx_idx != i) {
|
||||
temp_cnt = i - next_tx_idx;
|
||||
|
Reference in New Issue
Block a user