Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 24 Jan 2003 01:44:11 -0800
From:      Federico Andrade <federico@liquilan.com>
To:        freebsd-net@freebsd.org
Subject:   Adding bridge table lookup via sysctl()
Message-ID:  <5.1.0.14.2.20030124012414.00a9fb88@alicia.nttmcl.com>

next in thread | raw e-mail | index | archive | help
Hi all,

	I am doing some work based on the FreeBSD 4.7 bridge code, and want to add 
some "userland" table lookup capabilities. Right now I did this for a 
sysctl call:

(BTW, sorry if the code aesthetics are not the best, I promise to clean 
that up later):

##############################################################################
#define LOG(x) x
:
: Stuff in between...
:
static int sysctl_bridge_tl(SYSCTL_HANDLER_ARGS) {
if (do_bridge) {
int i,error,index;
char str_line[1024];

    for (i=0; i<n_clusters; i++) {
         bdg_hash_table *bdg_t  = clusters[i].ht;
         sprintf (str_line,"IDX#  MAC               IF   USED for CLUSTER: 
%d\n",clusters[i].cluster_id);
         error = SYSCTL_OUT(req, str_line, sizeof(str_line));

LOG(log(LOG_DEBUG,str_line);)
LOG(log(LOG_DEBUG,"Error code = %d\n",error);)

         if (error) return (error);

         for (index=0; index< HASH_SIZE; index++) {
                 if (bdg_t[index].name) {
                 sprintf (str_line,"%6d %6D %s%d 
%4d\n",index,bdg_t[index].etheraddr,":",
                 (bdg_t[index].name <= BDG_FORWARD) ? "X": 
bdg_t[index].name->if_name,
                 (bdg_t[index].name <= BDG_FORWARD) ? 0 : 
bdg_t[index].name->if_unit,bdg_t[index].used);

         error = SYSCTL_OUT(req, str_line, sizeof(str_line));

LOG(log(LOG_DEBUG,str_line);)
LOG(log(LOG_DEBUG,"Error code = %d\n",error);)

                 if (error) return (error);
} } } } }

SYSCTL_DECL(_net_link_ether);

SYSCTL_PROC(_net_link_ether, OID_AUTO, bridge_table, 
CTLTYPE_STRING|CTLFLAG_RD, NULL, 0, &sysctl_bridge_tl, "A", "Bridge table");

##############################################################################

The point is, if I do a "sysctl net.link.ether.bridge_table" on a terminal 
that is not the console, I don't get any result to this command, but I can 
see via the log (var/log/messages and the main console) something like this 
(from the log function):

Jan 24 01:00:04 eacs6 /kernel.BGE_FW2: IDX#  MAC               IF   USED 
for CLUSTER: 256
Jan 24 01:00:04 eacs6 /kernel.BGE_FW2: 292 00:60:ef:20:6e:04 vlan20    0
Jan 24 01:00:04 eacs6 /kernel.BGE_FW2: 306 00:60:ef:20:6e:12 vlan40    1
Jan 24 01:00:04 eacs6 /kernel.BGE_FW2: 1373 00:60:ef:20:aa:7d vlan10    1
Jan 24 01:00:04 eacs6 /kernel.BGE_FW2: 4820 00:50:73:46:61:92 fxp1    1
Jan 24 01:00:04 eacs6 /kernel.BGE_FW2: 5471 00:60:ef:20:9a:7f vlan30    1
Jan 24 01:00:04 eacs6 /kernel.BGE_FW2: IDX#  MAC               IF   USED 
for CLUSTER: 256

(The 256 I guess is because of the htons(), I'll check it later...)

The problem appears to be the function I am using for sending the results 
to the stdout of the user, but I am not that familiar with sysctl macros 
and functions... Any suggestions will be appreciated.

Regards,

		Federico.


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-net" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?5.1.0.14.2.20030124012414.00a9fb88>