Skip to contentSkip to conversation

struct nf_sockopt_ops

DISCUSSION Carl-Daniel Hailfinger 2 participants 2 messages Apr 16, 2005 – Apr 17, 2005 netfilter

lore
Share & tools
lore
#0 lore raw

Forgive me if that has already been discussed.

I'm wondering why the get and set members of the struct take some form of int as last parameter. Wouldn't be a long be the more logical choice? I can see changing the type here wouldn't help because nf_sockopt also accepting only an int for len.

struct nf_sockopt_ops
{
/* snip */

        int (*set)(struct sock *sk, int optval, void __user *user, unsigned int len);
/* snip */
        int (*get)(struct sock *sk, int optval, void __user *user, int *len);

/* snip */
};

Or at least the last parameter of the set member being a signed int to match the parameter to nf_sockopt.

Any insight into why the parameters were chosen that way would be truly appreciated.

Regards,
Carl-Daniel

#1 lore raw
Quoted 13 lines · Carl-Daniel Hailfinger

Forgive me if that has already been discussed.

I'm wondering why the get and set members of the struct take some form of int as last parameter. Wouldn't be a long be the more logical choice? I can see changing the type here wouldn't help because nf_sockopt also accepting only an int for len.

struct nf_sockopt_ops
{
/* snip */

        int (*set)(struct sock *sk, int optval, void __user *user, unsigned int len);
/* snip */
        int (*get)(struct sock *sk, int optval, void __user *user, int *len);
Quoted 8 lines

/* snip */
};

Or at least the last parameter of the set member being a signed int to match the parameter to nf_sockopt.

Any insight into why the parameters were chosen that way would be truly appreciated.

For compatibility. setsockopt(2):

The fifth argument of getsockopt and setsockopt is in reality an int [*] (and this is what BSD 4.* and libc4 and libc5 have). Some POSIX
confusion resulted in the present socklen_t, also used by glibc. See
also accept(2).

Regards
Patrick