This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Notes on static configuration of an eCos network interface


Notes on static configuration of an eCos network interface

1. Static interface configuration

A simple single-interface static configuration looks like this:

- IP address;
- subnet mask;
- broadcast address;
- default router IP address.

On occasion, there may be more than one router on the subnet, and in
that case there may be multiple routes (destination/mask/router
triplets).

In any case, these correspond to the following information in a BOOTP
message:

IP address:      ciaddr, or yiaddr if ciaddr was 0
subnet mask:     TAG_SUBNET_MASK
broadcast:       TAG_IP_BROADCAST
router address:  TAG_GATEWAY
multiple routes: TAG_IP_STATIC_ROUTES

The siaddr and giaddr fields of a BOOTP message are irrelevant to
configuring a network interface: they are used for talking to the
BOOTP server (e.g. for TFTPing a kernel).

2. Using the eCos config tool

Currently, the config tool defines the following five fields (for
eth0):

CYGHWR_NET_DRIVER_ETH0_ADDRS_IP
CYGHWR_NET_DRIVER_ETH0_ADDRS_NETMASK
CYGHWR_NET_DRIVER_ETH0_ADDRS_BROADCAST
CYGHWR_NET_DRIVER_ETH0_ADDRS_GATEWAY
CYGHWR_NET_DRIVER_ETH0_ADDRS_SERVER

Note that the "SERVER" field is meaningless on a non-bootp system.
Note that there's no way of setting up multiple static routes.

3. Building a BOOTP record

Then build_bootp_record() in network_support.c builds a bootp record
from this information as follows:

ciaddr = yiaddr = IP            ; good
siaddr = SERVER                 ; irrelevant
giaddr = GATEWAY                ; irrelevant
TAG_SUBNET_MASK : NETMASK       ; good
TAG_IP_BROADCAST : BROADCAST    ; good

Note that the GATEWAY field is plugged into giaddr, which tells the
BOOTP client what BOOTP gateway was used to talk to the BOOTP server
(named by SERVER).  This field is irrelevant for a non-bootp system.
So the "GATEWAY" config information is effectively thrown away.

I added code last week to add this to the bootp record:

TAG_GATEWAY : GATEWAY           ; if you add the code I posted last week

4. Initializing the interface

Then init_net() in bootp_support.c uses this bootp record to set up
the interface as follows:

SIOCSIFADDR, yiaddr                               ; good
SIOCSIFNETMASK, TAG_SUBNET_MASK                   ; good
SIOCSIFBRDADDR, TAG_IP_BROADCAST                  ; good
SIOCADDRT, yiaddr & netmask, netmask, TAG_GATEWAY ; bogus

This last line is bogus because the destination field (yiaddr &
netmask) is just the local subnet.  An interface configured like this
can't send packets outside the local subnet.  Suppose that the local
machine is 192.168.42.42/24, and the gateway is 192.168.42.69.  Then
this last gateway line sets up the following route:

route add 192.168.42.0 192.168.42.69 -netmask 255.255.255.0

That is, packets to the local subnet should be routed via the router.

In fact, to specify a default route, you should have a zero mask, and
can have a zero destination as well:

SIOCADDRT, 0, 0, TAG_GATEWAY                     ; better!

5. Recommendations

5.1. Config tool

Assuming the simple situation, with a default router and without
multiple static routes.  Then the config tool should be set up to
allow the specification of:

- IP address;           (as at present)
- subnet mask;          (as at present)
- broadcast address;    (as at present)
- router IP address.    ("gateway" at present)

and _not_ "server", which is a meaningless idea in the absence of
BOOTP.

5.2. building a BOOTP record:

build_bootp_record() shouldn't bother setting siaddr or giaddr, but
should put this information into the BOOTP record:

ciaddr = yiaddr = IP
TAG_SUBNET_MASK : NETMASK
TAG_IP_BROADCAST : BROADCAST
TAG_GATEWAY : GATEWAY

5.3. initializing the interface:

init_net() should initialize the interface as follows:

SIOCSIFADDR, yiaddr
SIOCSIFNETMASK, TAG_SUBNET_MASK
SIOCSIFBRDADDR, TAG_IP_BROADCAST
SIOCADDRT, 0, 0, TAG_GATEWAY

5.4. multiple static routes

The config tool, build_bootp_record() and init_net() should be
extended to allow the specification of multiple static routes, through
TAG_IP_STATIC_ROUTES.

5.5. DNS

A DNS resolver should be added and supported through
TAG_DOMAIN_SERVER.

Nick B

--
FreeBSD 2.2.8-RELEASE: up 15 days, 18:35
last reboot Sat Jul 1 19:26 (lightning strike)

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]