From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4606 invoked by alias); 15 May 2006 06:17:49 -0000 Received: (qmail 4593 invoked by uid 22791); 15 May 2006 06:17:48 -0000 X-Spam-Check-By: sourceware.org Received: from water.pku.edu.cn (HELO water.pku.edu.cn) (162.105.129.4) by sourceware.org (qpsmtpd/0.31) with ESMTP; Mon, 15 May 2006 06:17:45 +0000 Received: from water.pku.edu.cn (localhost [127.0.0.1]) by water.pku.edu.cn (iPlanet Messaging Server 5.2 Patch 2 (built Jul 14 2004)) with SMTP id <0IZA00LWZMTBK3@water.pku.edu.cn> for ecos-discuss@sources.redhat.com; Mon, 15 May 2006 14:17:35 +0800 (CST) Received: from unknown (HELO pku.edu.cn) (127.0.0.1) by localhost with SMTP; Mon, 15 May 2006 06:17:33 +0000 Received: from [162.105.76.250] (Forwarded-For: 162.105.75.123) by water.pku.edu.cn (mshttpd); Mon, 15 May 2006 14:17:33 +0800 X-Received: unknown,127.0.0.1,20060515141733 Date: Mon, 15 May 2006 06:17:00 -0000 From: =?gb2312?B?sszK9s/c?= To: ecos-discuss@sources.redhat.com Message-id: <199acfa199d194.199d194199acfa@pku.edu.cn> MIME-version: 1.0 X-Mailer: iPlanet Messenger Express 5.2 Patch 2 (built Jul 14 2004) Content-type: text/plain; charset=us-ascii Content-language: zh-CN Content-transfer-encoding: 7BIT Content-disposition: inline X-scanvirus: By EQAVSE AntiVirus Engine X-scanresult: CLEAN X-MAILFROM: X-RCPTTO: X-FROMIP: 127.0.0.1 Mailing-List: contact ecos-discuss-help@ecos.sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: ecos-discuss-owner@ecos.sourceware.org Subject: [ECOS] How to change MTU? X-SW-Source: 2006-05/txt/msg00105.txt.bz2 Hello, everyone! I am now implementing a router using eCos. I want to change the MTU of one of my two network interfaces. I tried to do that using the socket to kernel routing table, here is my code: //for route add and delete u_int32_t g,m,d; int routes; struct { struct rt_msghdr hdr; struct sockaddr_in dst; struct sockaddr_in gway; struct sockaddr_in mask; } rtmsg; if ((routes = socket(PF_ROUTE, SOCK_RAW, AF_INET)) < 0) { diag_printf("Error: route socket\n"); } //change route for MTU of eth1 g = 0x64300100; m = 0xFFFFFF00; d = 0x64300100; g = htonl(g); m = htonl(m); d = htonl(d); memset(&rtmsg, 0, sizeof(rtmsg)); rtmsg.hdr.rtm_type = RTM_CHANGE; rtmsg.hdr.rtm_flags = RTF_UP | RTF_HOST |RTF_STATIC; rtmsg.hdr.rtm_version = RTM_VERSION; rtmsg.hdr.rtm_seq = ++rtm_seq; rtmsg.hdr.rtm_addrs = RTA_DST | RTA_GATEWAY | RTA_NETMASK; rtmsg.hdr.rtm_rmx.rmx_locks = 0; rtmsg.hdr.rtm_rmx.rmx_mtu = 1000; rtmsg.dst.sin_len = sizeof(rtmsg.dst); rtmsg.dst.sin_family = AF_INET; rtmsg.dst.sin_addr.s_addr = d; rtmsg.gway.sin_len = sizeof(rtmsg.gway); rtmsg.gway.sin_family = AF_INET; rtmsg.gway.sin_addr.s_addr = g; rtmsg.mask.sin_len = sizeof(rtmsg.dst); rtmsg.mask.sin_family = AF_INET; rtmsg.mask.sin_addr.s_addr = m; rtmsg.hdr.rtm_msglen = sizeof(rtmsg); if (write(routes, &rtmsg, sizeof(rtmsg)) < 0) { diag_printf("Error:route change failed\n"); } close(routes); It seems that the write operation is successful, because I got no error message. But the MTU of my interface didn't change after that. Following is the output from show_network_tables(): Routing tables Destination Gateway Mask Flags Interface 100.48.1.0 100.48.1.0 255.255.255.0 U eth1 100.48.1.2 100.48.1.2 UH eth0 127.0.0.0 127.0.0.1 255.0.0.0 UG lo0 127.0.0.1 127.0.0.1 UH lo0 162.105.75.0 162.105.75.0 255.255.255.0 U eth0 162.105.78.0 100.48.1.2 255.255.255.0 UGS eth1 Interface statistics eth0 IP: 162.105.75.1, Broadcast: 162.105.75.255, Netmask: 255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU: 1500, Metric: 0 Rx - Packets: 0, Bytes: 0, Tx - Packets: 0, Bytes: 0 eth1 IP: 100.48.1.1, Broadcast: 100.48.1.255, Netmask: 255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU: 1500, Metric: 0 Rx - Packets: 0, Bytes: 0, Tx - Packets: 0, Bytes: 0 lo0 IP: 127.0.0.1, Broadcast: 127.0.0.1, Netmask: 255.0.0.0 UP LOOPBACK RUNNING MULTICAST MTU: 16384, Metric: 0 Rx - Packets: 0, Bytes: 0, Tx - Packets: 0, Bytes: 0 Why the MTU change didn't take effect? The MTU of eth1 is still 1500 but not 1000. Is there something wrong with my code? Anybody done similar operation before? Thank you very much for your suggestion! -- Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss