Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Backports:SLE-15-SP3:Update
icmptunnel
0002-Change-the-MTU-size-of-tunnel-23.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0002-Change-the-MTU-size-of-tunnel-23.patch of Package icmptunnel
From 5b7bdd5628c02e526cf71f2afdf63037f37782d9 Mon Sep 17 00:00:00 2001 From: YaoYu-Li <forever3580ya@gmail.com> Date: Thu, 23 Mar 2017 22:25:48 +0800 Subject: [PATCH 2/3] Change the MTU size of tunnel (#23) * Change the receive buffer in recv_icmp_packet() Since the maximum MTU of ethernet is 1500 bytes, the MTU of tunnel should be not more than 1500 - iphdr_size - icmphdr_size. So the tunnel MTU in both client and server site are up to 1472 bytes. * fixed tun MTU in script --- Makefile | 2 +- client.sh | 2 +- icmp.c | 11 +++++++---- icmp.h | 2 +- server.sh | 2 +- 5 files changed, 11 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 8c9b441..5ccc174 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ CC=gcc -CFLAGS=-I. +CFLAGS=-I. -O3 -Wall DEPS = icmp.h tunnel.h %.o: %.c $(DEPS) diff --git a/client.sh b/client.sh index 4597633..8387fb0 100755 --- a/client.sh +++ b/client.sh @@ -1,7 +1,7 @@ #!/bin/sh # Assigining an IP address and mask to 'tun0' interface -ifconfig tun0 mtu 1500 up 10.0.1.2 netmask 255.255.255.0 +ifconfig tun0 mtu 1472 up 10.0.1.2 netmask 255.255.255.0 # Modifying IP routing tables route del default diff --git a/icmp.c b/icmp.c index 4ce60d1..0cd1aa7 100644 --- a/icmp.c +++ b/icmp.c @@ -142,7 +142,7 @@ void send_icmp_packet(int sock_fd, struct icmp_packet *packet_details) void receive_icmp_packet(int sock_fd, struct icmp_packet *packet_details) { struct sockaddr_in src_addr; - struct sockaddr_in dest_addr; + //struct sockaddr_in dest_addr; struct iphdr *ip; struct icmphdr *icmp; @@ -151,9 +151,12 @@ void receive_icmp_packet(int sock_fd, struct icmp_packet *packet_details) int packet_size; char *packet; - int src_addr_size; + socklen_t src_addr_size; + int enc_MTU; //encapsulated MTU - packet = calloc(MTU, sizeof(uint8_t)); + enc_MTU = MTU + sizeof(struct iphdr) + sizeof(struct icmphdr); + + packet = calloc(enc_MTU, sizeof(uint8_t)); if (packet == NULL) { perror("No memory available\n"); close_icmp_socket(sock_fd); @@ -163,7 +166,7 @@ void receive_icmp_packet(int sock_fd, struct icmp_packet *packet_details) src_addr_size = sizeof(struct sockaddr_in); // Receiving packet - packet_size = recvfrom(sock_fd, packet, MTU, 0, (struct sockaddr *)&(src_addr), &src_addr_size); + packet_size = recvfrom(sock_fd, packet, enc_MTU, 0, (struct sockaddr *)&(src_addr), &src_addr_size); ip = (struct iphdr *)packet; icmp = (struct icmphdr *)(packet + sizeof(struct iphdr)); diff --git a/icmp.h b/icmp.h index a8302c5..c16ed87 100644 --- a/icmp.h +++ b/icmp.h @@ -6,7 +6,7 @@ #define icmp_guard // Maximum transmission unit -#define MTU 1500 +#define MTU 1472 struct icmp_packet { diff --git a/server.sh b/server.sh index dd1fdad..04dbaf3 100755 --- a/server.sh +++ b/server.sh @@ -1,7 +1,7 @@ #!/bin/sh # Assigining an IP address and mask to 'tun0' interface -ifconfig tun0 mtu 1500 up 10.0.1.1 netmask 255.255.255.0 +ifconfig tun0 mtu 1472 up 10.0.1.1 netmask 255.255.255.0 # Preventing the kernel to reply to any ICMP pings echo 1 | dd of=/proc/sys/net/ipv4/icmp_echo_ignore_all -- 2.16.4
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor