summaryrefslogtreecommitdiffstats
path: root/src/vnet/ip/ping.h
diff options
context:
space:
mode:
authorAndrew Yourtchenko <ayourtch@gmail.com>2017-01-28 15:31:19 +0000
committerNeale Ranns <nranns@cisco.com>2017-01-30 19:52:53 +0000
commit61459c9be0f620f738cf049b1b33e1a2d13dc9a6 (patch)
tree21932acc828c09e8b9b00ed1d8587d2b94a45224 /src/vnet/ip/ping.h
parentd03798c4eb860c30945c4ce881d2889a43ed4a93 (diff)
VPP-621: ping: ICMP echo data size must be bounded by VLIB_BUFFER_DATA_SIZE minus headers.
Before the commit 878c6098 the VLIB_BUFFER_DATA_SIZE was different depending on whether building "vpp" or "vpp_lite", resulting in an overrun in vpp_lite build. Avoid the hardcoded value and make the upper bound for ICMP echo data size dependent on the buffer size. Change-Id: Id6c4d7fc73766a95af2610eb237881b5fe9ce9aa Signed-off-by: Andrew Yourtchenko <ayourtch@gmail.com>
Diffstat (limited to 'src/vnet/ip/ping.h')
-rw-r--r--src/vnet/ip/ping.h45
1 files changed, 25 insertions, 20 deletions
diff --git a/src/vnet/ip/ping.h b/src/vnet/ip/ping.h
index 8f41f45c5f9..1887314a93c 100644
--- a/src/vnet/ip/ping.h
+++ b/src/vnet/ip/ping.h
@@ -59,26 +59,31 @@ ping_main_t ping_main;
#define PING_DEFAULT_DATA_LEN 60
#define PING_DEFAULT_INTERVAL 1.0
-#define PING_MAXIMUM_DATA_SIZE 2000
-
-typedef CLIB_PACKED (struct
- {
- u16 id;
- u16 seq; f64 time_sent; u8 data[PING_MAXIMUM_DATA_SIZE];
- }) icmp46_echo_request_t;
-
-
-typedef CLIB_PACKED (struct
- {
- ip6_header_t ip6;
- icmp46_header_t icmp; icmp46_echo_request_t icmp_echo;
- }) icmp6_echo_request_header_t;
-
-typedef CLIB_PACKED (struct
- {
- ip4_header_t ip4;
- icmp46_header_t icmp; icmp46_echo_request_t icmp_echo;
- }) icmp4_echo_request_header_t;
+#define PING_MAXIMUM_DATA_SIZE (VLIB_BUFFER_DATA_SIZE - sizeof(ip6_header_t) - sizeof(icmp46_header_t) - offsetof(icmp46_echo_request_t, data))
+
+/* *INDENT-OFF* */
+
+typedef CLIB_PACKED (struct {
+ u16 id;
+ u16 seq;
+ f64 time_sent;
+ u8 data[0];
+}) icmp46_echo_request_t;
+
+
+typedef CLIB_PACKED (struct {
+ ip6_header_t ip6;
+ icmp46_header_t icmp;
+ icmp46_echo_request_t icmp_echo;
+}) icmp6_echo_request_header_t;
+
+typedef CLIB_PACKED (struct {
+ ip4_header_t ip4;
+ icmp46_header_t icmp;
+ icmp46_echo_request_t icmp_echo;
+}) icmp4_echo_request_header_t;
+
+/* *INDENT-ON* */
typedef struct