lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <3fedcc3b0808302259p67e6d70bke1ff13f0902c2b1e@mail.gmail.com>
Date:	Sun, 31 Aug 2008 02:59:09 -0300
From:	"Thiago Lacerda" <thiagotbl@...il.com>
To:	netdev@...r.kernel.org
Subject: Problems with dev_add_pack()

Hi everyone,

I've registered a protocol handler with dev_add_pack, but seems that
it isn't capturing all the packets.
Every time that I receive an IP packet I increment a variable.
At the same time I am running my module I have a tcpdump instance
running (also capturing IP packets) and, when I stop both captures,
the counters (from tcpdump and from my module) differs from each other
(my module always capture less packets).

Does anyone know why that is happening?

Here is my code:

int my_handler (struct sk_buff *, struct net_device *, struct
packet_type *, struct net_device *);

struct packet_type pktype = {
        .type = __constant_htons(ETH_P_ALL),
        .func = my_handler,
};
unsigned int numberOfPackets;

static int init_mod(void) {
    printk(KERN_ALERT"Initializing Module\n");
    struct net_device* d = dev_get_by_name(&init_net, "eth1");
    if(d != NULL) {
        pktype.dev = d;
        dev_add_pack(&pktype);
    }
    numberOfPackets = 0;
    return 0;
}

static void exit_mod(void) {
    dev_remove_pack(&pktype);
    printk(KERN_ALERT"Exiting Module\n");
    printk(KERN_ALERT"Number of Packets: %u\n", numberOfPackets);
}

int my_handler (struct sk_buff * buff, struct net_device * dev, struct
packet_type * pt, struct net_device * dev2) {
    struct sk_buff* my_sock;
    my_sock = buff;
    if(!my_sock) {
        printk(KERN_ALERT"SK_BUFF NULL!!!!\n");
    }
    else {
        struct ethhdr* ethernet = eth_hdr(my_sock);
        if(ethernet->h_proto == __constant_htons(ETH_P_IP)) {
            numberOfPackets++;
        }
    }
    return 0;
}

Thanks in advance


--
Thiago de Barros Lacerda
Computer Science Undergraduate Student - CIn/UFPE - 2004.2
Researcher/Software Developer - GPRT - Networking and
Telecommunications Research Group
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ