Hello,

I just made some change of the bridge source which under kernel 2.4.20 ,to make 
it work automatically without any ioctl commands such as brctl .In this module 
I do ,it has only one br named BRIDGE which auto constructed in the module 
initiation ,and defined as a global variable "brg".And I add one eth card(eth0) 
to the br as a port .The main program is just below this page.

But now I meet one question ,that is ,when I want passup a skb to the higher 
protocol layer use function netif_rx ,the higher layer not response ,the skb 
must have not passup yet .Why ?I'm puzzling about it for some days .

Sorry my english is so poor:)

Thanks !
   
   
//my own bridge struct
struct Bridge{
        rwlock_t lock;
        rwlock_t hash_lock;
        struct net_device dev;
        struct Bridge_fdb_entry *hash[BR_HASH_SIZE];
};

extern struct Bridge *brg;

//the bridge initiation , will be called in module_init
struct Bridge *Bridge_fdb_init()
{
        struct Bridge *br;
        if ((br = kmalloc(sizeof(*br),GFP_KERNEL)) == NULL)
                return NULL;
                
        memset(br,0,sizeof(*br));
        strncpy(br->dev.name,"BRIDGE",IFNAMSIZ);
        ether_setup(&br->dev);
        Bridge_dev_setup(&br->dev);
        
        br->lock = RW_LOCK_UNLOCKED;
        br->hash_lock = RW_LOCK_UNLOCKED;
        
        register_netdev(&br->dev);
//      netif_start_queue(&br->dev);

        ethdev = dev_get_by_name("eth0");
        ethdev->br_port = (struct net_bridge_port *)br;
        dev_set_promiscuity(ethdev,1);
        dev_hold(ethdev);
        return br;
}

static void Bridge_passup(struct sk_buff *skb)
{
        skb->dev = &brg->dev;
        skb->pkt_type = PACKET_HOST;
        skb_push(skb,ETH_HLEN);
        skb->protocol = eth_type_trans(skb,&brg->dev);
        netif_rx(skb);
        return;
}

void Bridge_dev_setup(struct net_device *dev)
{
        unsigned char dd[6] = {0x12,0x12,0x12,0x12,0x12,0x12};
        memcpy(dev->dev_addr,dd,ETH_ALEN);
        dev->do_ioctl = NULL;
        dev->get_stats = NULL;
        dev->hard_start_xmit = NULL;
        dev->open = NULL;
        dev->set_multicast_list = NULL;
        dev->stop = NULL;
        dev->accept_fastpath = NULL;
        dev->tx_queue_len = 0;
        dev->set_mac_address = NULL;
}
[EMAIL PROTECTED]
          2005-04-24

_______________________________________________
Bridge mailing list
[email protected]
http://lists.osdl.org/mailman/listinfo/bridge

Reply via email to