Someone posted such a question here.
Personally, I started to hack the Linux kernel when developing a new networking suite called the ATN TP4/CLNP Networking Suite for use with GNU/Linux systems in the aeronautical industry. So, I have some suggestions here.
SOCK_ZAPPED, which is defined in include/net/sock.h, is a status flag of a socket (struct sock) to indicate that the socket has a name assigned to it already (i.e., the socket is bound with bind()).
Archive: Linux Kernel's Networking Part (Networking Socket)
It turned out that any wireless Ethernet card's device driver in a non-promiscuous mode does not drop any Ethernet frame with the following destination MAC address:
YY:xx:xx:xx:xx:xx, where YY is an odd number (e.g., 0xE1, 0x11, 0x01, etc.)
Just yesterday my friend and I were wondering why his Linux kernel module crashed the kernel in QEMU everytime the module was removed with rmmod; it caused the kernel to issue the BUG message on the screen before crashing. The kernel module itself had just been transfered from his host GNU/Linux operating system via scp.
If you are wondering why:
ping 224.0.0.1
does not give you anything back from your localhost or other hosts that are running Linux kernel 2.6, it is because, in Linux kernel 2.6, the capability of ICMP to reply to broadcast/multicast ping message is disabled by default. Whereas, it is enabled by default in Linux kernel 2.4.
If skb is linear (i.e., skb->data_len == 0), the length of skb->data is skb->len.
A call to fgetc() or getchar() will return EOF if the end-of-file has been reached.
As far as I know, GNU C Library defines EOF to be (-1).
Those who are unwary will think that those functions return a char.
Now a char has a range from 0x00 to 0xFF because its size is one byte.
However, if EOF is returned as a char, which must take one value from the range, there will be no way to differentiate whether or not the returned char is actually a byte read from the stream or EOF to signal that the end-of-file has been reached already.
That error message is issued because a version mismatch occurs when the Linux kernel module to be inserted into the working kernel was not compiled with the source code that was used to compile the working Linux kernel.
As an example, let's use Realtek 8139 as the NIC.
cp_rx_poll(): desc = &cp->rx_ring[rx_tail]; | status = le32_to_cpu(desc->opts1); | len = (status & 0x1fff) - 4; | V dev_alloc_skb(): skb->len = 0 | V skb_put(): skb->len += len
Looking at the man page of printf (man 3 printf), in the length modifier section, it is written:
z A following integer conversion corresponds to a
size_torssize_targument. (Linux libc5 hasZwith this meaning. Don't use it.)
Therefore,
size_t x = sizeof (int);
printf ("%zd\n", x);
Consider the following struct and program:
#include <stdio.h>
#include <stdlib.h>
struct fix_data
{
char data [5];
unsigned char optional_part [0];
} __attribute__ ((packed));
int main (int argc, char **argv, char **envp)
{
char buffer [10] = "Name\0emaN\0";
int i = 0;
struct fix_data *ptr = (struct fix_data *) buffer;
It is a universal truth that with or without the extern keyword a function prototype will just do the same. So, why does almost all function prototypes in Linux kernel source code prefixed with the extern keyword?
Looking at Getting the offset of a member in a struct, I realized that you can also use the same technique to get the size of a member of a struct or a union without declaring a variable of that struct. Suppose a struct has been defined as follows:
struct person
{
int id;
char name [50];
double salary;
};
struct aligned_struct
{
char a [5];
int b;
};
I found in Linux kernel 2.6.21.5 in include/net/netinet_hastables.h in function __inet_lookup this interesting expression:
return sk ? : __inet_lookup_listener(hashinfo, daddr, hnum, dif);