Skip to content

Commit

Permalink
Increase maximum -s value to 65507
Browse files Browse the repository at this point in the history
Correct definitions: maximum theoretical IPv4 packet size and minimum
IPv4 header size (previously probably IPv6 size was used).

Because fping does not know ahead whether address is IPv4 or IPv6 assume
IPv4. Previously fping allowed only 65488, but real maximum for IPv4 on
Linux is 65507 (IPv6 would allow 65527, but fping unlike ping from
iputils does not try print errno when it fails on higher value, thus
follow the current approach and allow smaller value than reachable for
IPv6).

Update test affected by this change. While at this, test 65508 (one
above the limit) instead of 65509.

Signed-off-by: Petr Vorel <pvorel@suse.cz>
  • Loading branch information
pevik committed Aug 18, 2024
1 parent 54f452c commit f9fd6bc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions ci/test-03-forbidden.pl
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ END
$cmd7->stdout_is_eq("");
$cmd7->stderr_is_eq("fping: specify only one of c, l\n");

# fping -b 65509
my $cmd8 = Test::Command->new(cmd => "fping -b 65509 127.0.0.1");
# fping -b 65508
my $cmd8 = Test::Command->new(cmd => "fping -b 65508 127.0.0.1");
$cmd8->exit_is_num(1);
$cmd8->stdout_is_eq("");
$cmd8->stderr_is_eq("fping: data size 65509 not valid, must be lower than 65488\n");
$cmd8->stderr_is_eq("fping: data size 65508 not valid, must be lower than 65507\n");

# fping -B 0.9
my $cmd9 = Test::Command->new(cmd => "fping -B 0.9 127.0.0.1");
Expand Down
4 changes: 2 additions & 2 deletions src/fping.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ extern int h_errno;

/*** Ping packet defines ***/

#define MAX_IP_PACKET 65536 /* (theoretical) max IP packet size */
#define SIZE_IP_HDR 40
#define MAX_IP_PACKET 65535 /* (theoretical) max IPv4 packet size */
#define SIZE_IP_HDR 20 /* min IPv4 header size */
#define SIZE_ICMP_HDR 8 /* from ip_icmp.h */
#define MAX_PING_DATA (MAX_IP_PACKET - SIZE_IP_HDR - SIZE_ICMP_HDR)

Expand Down

0 comments on commit f9fd6bc

Please sign in to comment.