X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvnet%2Fudp%2Fudp_pg.c;h=621beb792770e0cf2f653723ca4814e3e50304c6;hb=c5df8c71c;hp=c9d8d38ca4a397f5a4b107afeb32ea161de996ba;hpb=68b0fb0c620c7451ef1a6380c43c39de6614db51;p=vpp.git diff --git a/src/vnet/udp/udp_pg.c b/src/vnet/udp/udp_pg.c index c9d8d38ca4a..621beb79277 100644 --- a/src/vnet/udp/udp_pg.c +++ b/src/vnet/udp/udp_pg.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Cisco and/or its affiliates. + * Copyright (c) 2015-2019 Cisco and/or its affiliates. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at: @@ -39,6 +39,7 @@ #include #include /* for unformat_udp_udp_port */ +#include #define UDP_PG_EDIT_LENGTH (1 << 0) #define UDP_PG_EDIT_CHECKSUM (1 << 1) @@ -68,12 +69,12 @@ udp_pg_edit_function_inline (pg_main_t * pg, ip0 = (void *) (p0->data + ip_offset); udp0 = (void *) (p0->data + udp_offset); - udp_len0 = clib_net_to_host_u16 (ip0->length) - sizeof (ip0[0]); + udp_len0 = vlib_buffer_length_in_chain (vm, p0) - udp_offset; if (flags & UDP_PG_EDIT_LENGTH) - udp0->length = - clib_net_to_host_u16 (vlib_buffer_length_in_chain (vm, p0) - - ip_offset); + udp0->length = clib_host_to_net_u16 (udp_len0); + else + udp_len0 = clib_host_to_net_u16 (udp0->length); /* Initialize checksum with header. */ if (flags & UDP_PG_EDIT_CHECKSUM) @@ -191,17 +192,25 @@ unformat_pg_udp_header (unformat_input_t * input, va_list * args) u16 dst_port; tcp_udp_port_info_t *pi; + /* For the pg format of applications over UDP local */ + udp_dst_port_info_t *pi2 = NULL; + pi = 0; if (p->dst_port.type == PG_EDIT_FIXED) { dst_port = pg_edit_get_value (&p->dst_port, PG_EDIT_LO); pi = ip_get_tcp_udp_port_info (im, dst_port); + pi2 = udp_get_dst_port_info (&udp_main, dst_port, UDP_IP4); + if (!pi2) + pi2 = udp_get_dst_port_info (&udp_main, dst_port, UDP_IP6); } if (pi && pi->unformat_pg_edit && unformat_user (input, pi->unformat_pg_edit, s)) ; - + else if (pi2 && pi2->unformat_pg_edit + && unformat_user (input, pi2->unformat_pg_edit, s)) + ; else if (!unformat_user (input, unformat_pg_payload, s)) goto error;