From: Stanislav Meduna <stano@meduna.org>
To: Tarmo Kuuse <tarmo.kuuse@mail.ee>,
eCos Discussion <ecos-discuss@ecos.sourceware.org>
Subject: Re: [ECOS] Re: How to deconfigure an interface?
Date: Tue, 01 Sep 2009 09:59:00 -0000 [thread overview]
Message-ID: <4A9CF045.4060107@meduna.org> (raw)
In-Reply-To: <h7inou$i9b$1@ger.gmane.org>
Tarmo Kuuse wrote:
> There could be a better way, but I just do SIOCGIFADDR to read the
> current addresses from an interface and delete them with SIOCDIFADDR. As
> input, the "struct ifreq" needs the interface's textual name (e.g.
> "eth0"). Works fine.
Yes, that's the same I'm doing now.
> Another task which needs doing is clearing the routes table. There
> exists a function "cyg_route_reinit()" which simply flushes all routes.
> Unfortunately it also deletes routes for the local loopback and all
> other interfaces you may have. I haven't yet figured out how to delete
> the routes only for a given interface.
I added such a function, it seems to work.
In net\common\current\include:
===================================================================
RCS file: /cvs/ecos/ecos-opt/net/net/common/current/include/network.h,v
retrieving revision 1.6
diff -u -r1.6 network.h
--- network.h 29 Jan 2009 17:49:57 -0000 1.6
+++ network.h 1 Sep 2009 09:36:34 -0000
@@ -68,6 +68,7 @@
__externC void init_all_network_interfaces(void);
__externC void cyg_route_reinit(void);
+__externC void cyg_route_reinit_iface(const char *);
__externC void perror(const char *) __THROW;
__externC int close(int);
__externC ssize_t read(int, void *, size_t);
In net\bsd_tcpip\current\src\sys\net:
===================================================================
RCS file: /cvs/ecos/ecos-opt/net/net/bsd_tcpip/current/src/sys/net/route.c,v
retrieving revision 1.5
diff -u -r1.5 route.c
--- route.c 29 Jan 2009 17:49:56 -0000 1.5
+++ route.c 1 Sep 2009 09:42:34 -0000
@@ -79,6 +79,8 @@
struct sockaddr *, struct sockaddr *));
static void rtable_init __P((void **));
+externC void if_indextoname(int indx, char *buf, int len);
+
static void
rtable_init(table)
void **table;
@@ -116,6 +118,14 @@
{
struct rtentry *rt = (struct rtentry *)rn;
if (rt->rt_ifa->ifa_addr->sa_family == AF_INET) {
+ int dodel = (vifp == NULL);
+ if (! dodel) {
+ char ifname[64];
+ if_indextoname(rt->rt_ifp->if_index, ifname, 64);
+ dodel = ! strcmp(ifname, (const char *) vifp);
+ }
+
+ if (dodel)
rtrequest(RTM_DELETE, rt_key(rt), rt->rt_gateway, rt_mask(rt),
0, NULL);
}
@@ -135,6 +145,19 @@
}
}
+void
+cyg_route_reinit_iface(const char *iface)
+{
+ int i;
+ for (i = 0; i < AF_MAX+1; i++) {
+ struct radix_node_head *rnh;
+ rnh = rt_tables[i];
+ if (rnh) {
+ (*rnh->rnh_walktree)(rnh, rt_reinit_rtdelete, (void *) iface);
+ }
+ }
+}
+
/*
* Packet routing routines.
*/
Regards
--
Stano
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
next prev parent reply other threads:[~2009-09-01 9:59 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-31 16:58 [ECOS] " Stanislav Meduna
2009-09-01 8:59 ` [ECOS] " Tarmo Kuuse
2009-09-01 9:59 ` Stanislav Meduna [this message]
2009-09-01 13:59 ` Tarmo Kuuse
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4A9CF045.4060107@meduna.org \
--to=stano@meduna.org \
--cc=ecos-discuss@ecos.sourceware.org \
--cc=tarmo.kuuse@mail.ee \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).