Commit f733bc48 authored by Arnaldo Carvalho de Melo's avatar Arnaldo Carvalho de Melo Committed by David S. Miller

[LLC]: fix client side after sockaddr_llc fixup

parent ea2141fa
...@@ -250,41 +250,19 @@ static int llc_ui_autobind(struct socket *sock, struct sockaddr_llc *addr) ...@@ -250,41 +250,19 @@ static int llc_ui_autobind(struct socket *sock, struct sockaddr_llc *addr)
if (!sk->sk_zapped) if (!sk->sk_zapped)
goto out; goto out;
/* bind to a specific sap, optional. */ rc = -ENODEV;
if (!addr->sllc_sap) { llc->dev = dev_getfirstbyhwtype(addr->sllc_arphrd);
rc = -EUSERS; if (!llc->dev)
addr->sllc_sap = llc_ui_autoport(); goto out;
if (!addr->sllc_sap) rc = -EUSERS;
goto out; llc->laddr.lsap = llc_ui_autoport();
} if (!llc->laddr.lsap)
sap = llc_sap_find(addr->sllc_sap); goto out;
if (!sap) { rc = -EBUSY; /* some other network layer is using the sap */
sap = llc_sap_open(addr->sllc_sap, NULL); sap = llc_sap_open(llc->laddr.lsap, NULL);
rc = -EBUSY; /* some other network layer is using the sap */ if (!sap)
if (!sap) goto out;
goto out; memcpy(llc->laddr.mac, llc->dev->dev_addr, IFHWADDRLEN);
} else {
struct llc_addr laddr, daddr;
struct sock *ask;
memset(&laddr, 0, sizeof(laddr));
memset(&daddr, 0, sizeof(daddr));
/*
* FIXME: check if the the address is multicast,
* only SOCK_DGRAM can do this.
*/
memcpy(laddr.mac, addr->sllc_mac, IFHWADDRLEN);
laddr.lsap = addr->sllc_sap;
rc = -EADDRINUSE; /* mac + sap clash. */
ask = llc_lookup_established(sap, &daddr, &laddr);
if (ask) {
sock_put(ask);
goto out;
}
}
llc->laddr.lsap = addr->sllc_sap;
if (llc->dev)
memcpy(llc->laddr.mac, llc->dev->dev_addr, IFHWADDRLEN);
memcpy(&llc->addr, addr, sizeof(llc->addr)); memcpy(&llc->addr, addr, sizeof(llc->addr));
/* assign new connection to its SAP */ /* assign new connection to its SAP */
llc_sap_add_socket(sap, sk); llc_sap_add_socket(sap, sk);
...@@ -315,6 +293,8 @@ static int llc_ui_bind(struct socket *sock, struct sockaddr *uaddr, int addrlen) ...@@ -315,6 +293,8 @@ static int llc_ui_bind(struct socket *sock, struct sockaddr *uaddr, int addrlen)
{ {
struct sockaddr_llc *addr = (struct sockaddr_llc *)uaddr; struct sockaddr_llc *addr = (struct sockaddr_llc *)uaddr;
struct sock *sk = sock->sk; struct sock *sk = sock->sk;
struct llc_opt *llc = llc_sk(sk);
struct llc_sap *sap;
int rc = -EINVAL; int rc = -EINVAL;
dprintk("%s: binding %02X\n", __FUNCTION__, addr->sllc_sap); dprintk("%s: binding %02X\n", __FUNCTION__, addr->sllc_sap);
...@@ -323,8 +303,43 @@ static int llc_ui_bind(struct socket *sock, struct sockaddr *uaddr, int addrlen) ...@@ -323,8 +303,43 @@ static int llc_ui_bind(struct socket *sock, struct sockaddr *uaddr, int addrlen)
rc = -EAFNOSUPPORT; rc = -EAFNOSUPPORT;
if (addr->sllc_family != AF_LLC) if (addr->sllc_family != AF_LLC)
goto out; goto out;
/* use autobind, to avoid code replication. */ if (!addr->sllc_sap) {
rc = llc_ui_autobind(sock, addr); rc = -EUSERS;
addr->sllc_sap = llc_ui_autoport();
if (!addr->sllc_sap)
goto out;
}
sap = llc_sap_find(addr->sllc_sap);
if (!sap) {
sap = llc_sap_open(addr->sllc_sap, NULL);
rc = -EBUSY; /* some other network layer is using the sap */
if (!sap)
goto out;
} else {
struct llc_addr laddr, daddr;
struct sock *ask;
memset(&laddr, 0, sizeof(laddr));
memset(&daddr, 0, sizeof(daddr));
/*
* FIXME: check if the the address is multicast,
* only SOCK_DGRAM can do this.
*/
memcpy(laddr.mac, addr->sllc_mac, IFHWADDRLEN);
laddr.lsap = addr->sllc_sap;
rc = -EADDRINUSE; /* mac + sap clash. */
ask = llc_lookup_established(sap, &daddr, &laddr);
if (ask) {
sock_put(ask);
goto out;
}
}
llc->laddr.lsap = addr->sllc_sap;
memcpy(llc->laddr.mac, addr->sllc_mac, IFHWADDRLEN);
memcpy(&llc->addr, addr, sizeof(llc->addr));
/* assign new connection to its SAP */
llc_sap_add_socket(sap, sk);
rc = sk->sk_zapped = 0;
out: out:
return rc; return rc;
} }
...@@ -399,15 +414,7 @@ static int llc_ui_connect(struct socket *sock, struct sockaddr *uaddr, ...@@ -399,15 +414,7 @@ static int llc_ui_connect(struct socket *sock, struct sockaddr *uaddr,
llc->daddr.lsap = addr->sllc_sap; llc->daddr.lsap = addr->sllc_sap;
memcpy(llc->daddr.mac, addr->sllc_mac, IFHWADDRLEN); memcpy(llc->daddr.mac, addr->sllc_mac, IFHWADDRLEN);
} }
if (!llc->dev) { dev = llc->dev;
rc = -ENODEV;
dev = dev_getfirstbyhwtype(addr->sllc_arphrd);
if (!dev)
goto out;
llc->dev = dev;
memcpy(llc->laddr.mac, llc->dev->dev_addr, IFHWADDRLEN);
} else
dev = llc->dev;
if (sk->sk_type != SOCK_STREAM) if (sk->sk_type != SOCK_STREAM)
goto out; goto out;
rc = -EALREADY; rc = -EALREADY;
...@@ -610,7 +617,7 @@ static int llc_ui_accept(struct socket *sock, struct socket *newsock, int flags) ...@@ -610,7 +617,7 @@ static int llc_ui_accept(struct socket *sock, struct socket *newsock, int flags)
int rc = -EOPNOTSUPP; int rc = -EOPNOTSUPP;
dprintk("%s: accepting on %02X\n", __FUNCTION__, dprintk("%s: accepting on %02X\n", __FUNCTION__,
llc_sk(sk)->addr.sllc_sap); llc_sk(sk)->laddr.lsap);
lock_sock(sk); lock_sock(sk);
if (sk->sk_type != SOCK_STREAM) if (sk->sk_type != SOCK_STREAM)
goto out; goto out;
...@@ -622,7 +629,7 @@ static int llc_ui_accept(struct socket *sock, struct socket *newsock, int flags) ...@@ -622,7 +629,7 @@ static int llc_ui_accept(struct socket *sock, struct socket *newsock, int flags)
if (rc) if (rc)
goto out; goto out;
dprintk("%s: got a new connection on %02X\n", __FUNCTION__, dprintk("%s: got a new connection on %02X\n", __FUNCTION__,
llc_sk(sk)->addr.sllc_sap); llc_sk(sk)->laddr.lsap);
skb = skb_dequeue(&sk->sk_receive_queue); skb = skb_dequeue(&sk->sk_receive_queue);
rc = -EINVAL; rc = -EINVAL;
if (!skb->sk) if (!skb->sk)
...@@ -747,13 +754,7 @@ static int llc_ui_sendmsg(struct kiocb *iocb, struct socket *sock, ...@@ -747,13 +754,7 @@ static int llc_ui_sendmsg(struct kiocb *iocb, struct socket *sock,
if (rc) if (rc)
goto release; goto release;
} }
if (!llc->dev) { dev = llc->dev;
rc = -ENODEV;
dev = dev_getfirstbyhwtype(addr->sllc_arphrd);
if (!dev)
goto release;
} else
dev = llc->dev;
hdrlen = dev->hard_header_len + llc_ui_header_len(sk, addr); hdrlen = dev->hard_header_len + llc_ui_header_len(sk, addr);
size = hdrlen + len; size = hdrlen + len;
if (size > dev->mtu) if (size > dev->mtu)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment