Bug 5156 - llc2: llc_ui_bind() leaves llc->dev NULL
Summary: llc2: llc_ui_bind() leaves llc->dev NULL
Status: CLOSED CODE_FIX
Alias: None
Product: Networking
Classification: Unclassified
Component: Other (show other bugs)
Hardware: i386 Linux
: P2 normal
Assignee: Arnaldo Carvalho de Melo
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-08-30 07:24 UTC by Jochen Friedrich
Modified: 2006-02-05 10:47 UTC (History)
0 users

See Also:
Kernel Version: 2.6.11
Subsystem:
Regression: ---
Bisected commit-id:


Attachments

Description Jochen Friedrich 2005-08-30 07:24:46 UTC
Most recent kernel where this bug did not occur: - 
Distribution: Debian
Hardware Environment: Alpha / Intel
Problem Description:

binding LLC stream sockets to a local address leaves llc->dev = NULL.
A later connect() causes Oops in llc_establish_connection().

Steps to reproduce:

#undef __GLIBC__
#include <linux/socket.h>
#include <asm/socket.h>
#include <linux/if_ether.h>
#include <linux/if_arp.h>
#include <linux/if_packet.h>
#include <linux/llc.h>
#define __GLIBC__
#define SOCK_DGRAM 2
#define SOCK_STREAM 1

static void
get_hwaddr (unsigned char *name, unsigned char *addr, short int *type)
{
  struct ifreq ifr;
  int fd = socket (AF_INET, SOCK_DGRAM, 0);

  if (fd < 0)
    {
      printf ("socket failed\n");
      return;
    }
  bcopy (name, &ifr.ifr_name, sizeof (ifr.ifr_name));


  /* find my own hardware address */
  if (ioctl (fd, SIOCGIFHWADDR, &ifr) < 0)
    {
      close (fd);
      printf ("ioctl(SIOCGIFHWADDR) failed\n");
      return;
    }
  close (fd);
  bcopy (&ifr.ifr_hwaddr.sa_data, addr, ETH_ALEN);
  *type = ifr.ifr_hwaddr.sa_family;
}

int llc_open (unsigned char sap, char *name)
{
  struct sockaddr_llc sllc;
  short int type;
  int fd;
  unsigned char smac[ETH_ALEN];

  fd = socket (PF_LLC, SOCK_STREAM, 0);
  if (fd < 0)
    {
      printf ("socket failed\n");
      return -1;
    }

  get_hwaddr (name, smac, &type);

  bzero (&sllc, sizeof (sllc));
  sllc.sllc_family = AF_LLC;
  sllc.sllc_arphrd = type;
  sllc.sllc_sap = 0xc2;
  bcopy (smac, &sllc.sllc_mac, ETH_ALEN);

  if (bind (fd, &sllc, sizeof (sllc)) < 0)
    {
      close (fd);
      printf ("bind failed\n");
      return -1;
    }

  bzero (&sllc, sizeof (sllc));
  sllc.sllc_family = AF_LLC;
  sllc.sllc_arphrd = type;
  sllc.sllc_sap = 232;
  sllc.sllc_mac[0] = 0x10;
  sllc.sllc_mac[1] = 0x00;
  sllc.sllc_mac[2] = 0x90;
  sllc.sllc_mac[3] = 0x9a;
  sllc.sllc_mac[4] = 0x30;
  sllc.sllc_mac[5] = 0x9c;
  if (connect (fd, &sllc, sizeof (sllc)) < 0)
    {
      close (fd);
      printf ("connect failed\n");
      return -1;
    }

  return fd;
}

int main()
{
  char name[] = "eth0";
  int fd;

  fd = llc_open(232,name);
}
Comment 1 Andrew Morton 2005-08-30 11:20:20 UTC
Can you test 2.6.13 please?
Comment 2 Jochen Friedrich 2005-08-31 03:37:57 UTC
The LLC code hasn't been touched since 2.6.11. Current netdev-2.6.git#ALL has
the same problem (tested on alpha).
Comment 3 Jochen Friedrich 2006-02-05 10:47:36 UTC
Bug has been fixed in 2.6.15.

Note You need to log in before you can comment on or make changes to this bug.