linuxulator problems in linux_socket.c (and friends)

Andrew Atrens atrens at nortelnetworks.com
Tue Jan 6 22:57:27 PST 2004


Oops, with all the crashing and rebooting my realtime clock got a bit 
skewed :(

This change seems to have been introduced in -

http://gomerbud.com/daver/patches/dragonfly/linux-no43-3.diff

by David Reese ...

Looks like

-/* Return 0 if IP_HDRINCL is set for the given socket. */
-static int
-linux_check_hdrincl(int s)
-{
and

-/*
- * Updated sendto() when IP_HDRINCL is set:
- * tweak endian-dependent fields in the IP packet.
- */
-static int
-linux_sendto_hdrincl(struct sendto_args *bsd_args)
were removed.

Indeed, looks like

linux_check_hdrincl() did something fancy when calling getsockopt()

-	sg = stackgap_init();
-	val = stackgap_alloc(&sg, sizeof(int));
-	valsize = stackgap_alloc(&sg, sizeof(int));
-
-	if ((error = copyout(&size_val, valsize, sizeof(size_val))))
-		return (error);
-
-	bsd_args.s = s;
-	bsd_args.level = IPPROTO_IP;
-	bsd_args.name = IP_HDRINCL;
-	bsd_args.val = val;
-	bsd_args.avalsize = (int *)valsize;
-	bsd_args.sysmsg_result = 0;
-	if ((error = getsockopt(&bsd_args)))
-		return (error);
-	/* return value not used */
-
-	if ((error = copyin(val, &optval, sizeof(optval))))
-		return (error);
-
this was replaced by the below ref'd code that now calls 
kern_getsockopt() without doing the stackgap_alloc/copyin/copyout ...

Not sure why all that was in there, but if I have some time on Thursday 
I'll take a run at it :P

Cheers,

Andrew.



Andrew Atrens wrote:
Hi All,

I've had clearcase 5.0 running on FreeBSD-stable for quite some time 
(probably 3+ years) and I thought I'd give it a try on DragonFly ...

Well, the short version is that it doesn't work... and I've not found a 
workaround -

in linux_socket.c -

kern_getsockopt() (quoted below) is failing with error 42...

#define ENOPROTOOPT     42              /* Protocol not available */

If I kludge around the error by forcing both error and sopt to zero, I 
can get simple commands to work, but this is clearly not the right thing
to do.

linux_socket.c is very different in df from what's in 4.9. Looks like 
the df version has been substantially refactored.

In 4.9 IP_HDRINCL sockets are treated very specially (with their own 
special identification test func. and special sendto func as well). 
Don't know if this is required in df, but what's there now doesn't work 
for me :(

I'd certainly like to get this working ... let me know how you'd like me 
  to proceed.

Cheers,

Andrew.



static int
linux_sendto(struct linux_sendto_args *args, int *res)
{
    struct linux_sendto_args linux_args;
    struct thread *td = curthread;
    struct uio auio;
    struct iovec aiov;
    struct sockopt sopt;
    struct sockaddr *sa = NULL;
    caddr_t msg = NULL;
    int error, optval;
    error = copyin(args, &linux_args, sizeof(linux_args));
    if (error)
        return (error);
    if (linux_args.to) {
        error = linux_getsockaddr(&sa, linux_args.to,
            linux_args.tolen);
        if (error)
            return (error);
    }
    /*
     * Check to see if the IP_HDRINCL option is set.
     */
    sopt.sopt_dir = SOPT_GET;
    sopt.sopt_level = IPPROTO_IP;
    sopt.sopt_name = IP_HDRINCL;
    sopt.sopt_val = &optval;
    sopt.sopt_valsize = sizeof(optval);
    sopt.sopt_td = NULL;
    error = kern_getsockopt(linux_args.s, &sopt);    <--- returns 42

    error = sopt = 0 ; /* BROKEN: assume the option is not set */

    if (error)
        return (error);






More information about the Bugs mailing list