[LLC]: when the user doesn't specifies a local address to connect, do an autobind

Other protocols do this as soon as they discover over what interface the
packet will be routed, but LLC isn't routable, so, to provide similar
semantics to the other protocols, I'm just binding it to the first interface
of the type specified, perhaps we'll need a tunable for this or some sort of
routing table done manually by the admin, later we'll see, for now this
allows an application like openssh, with patched getaddrinfo/getnameinfo to
use PF_LLC sockets with a very small patch.
parent fbe0d04d
...@@ -389,9 +389,9 @@ static int llc_ui_shutdown(struct socket *sock, int how) ...@@ -389,9 +389,9 @@ static int llc_ui_shutdown(struct socket *sock, int how)
* @flags: Operational flags specified by the user. * @flags: Operational flags specified by the user.
* *
* Connect to a remote llc2 mac + sap. The caller must specify the * Connect to a remote llc2 mac + sap. The caller must specify the
* destination mac and address to connect to. If the user previously * destination mac and address to connect to. If the user hasn't previously
* called bind(2) with a smac the user does not need to specify the source * called bind(2) with a smac the address of the first interface of the
* address and mac. * specified arp type will be used.
* This function will autobind if user did not previously call bind. * This function will autobind if user did not previously call bind.
* Returns: 0 upon success, negative otherwise. * Returns: 0 upon success, negative otherwise.
*/ */
...@@ -419,9 +419,7 @@ static int llc_ui_connect(struct socket *sock, struct sockaddr *uaddr, ...@@ -419,9 +419,7 @@ static int llc_ui_connect(struct socket *sock, struct sockaddr *uaddr,
} }
if (!llc->dev) { if (!llc->dev) {
rc = -ENODEV; rc = -ENODEV;
rtnl_lock(); dev = dev_getfirstbyhwtype(addr->sllc_arphrd);
dev = dev_getbyhwaddr(addr->sllc_arphrd, addr->sllc_smac);
rtnl_unlock();
if (!dev) if (!dev)
goto out; goto out;
llc->dev = dev; llc->dev = dev;
...@@ -770,10 +768,8 @@ static int llc_ui_sendmsg(struct kiocb *iocb, struct socket *sock, ...@@ -770,10 +768,8 @@ static int llc_ui_sendmsg(struct kiocb *iocb, struct socket *sock,
goto release; goto release;
} }
if (!llc->dev) { if (!llc->dev) {
rtnl_lock(); rc = -ENODEV;
dev = dev_getbyhwaddr(addr->sllc_arphrd, addr->sllc_smac); dev = dev_getfirstbyhwtype(addr->sllc_arphrd);
rtnl_unlock();
rc = -ENETUNREACH;
if (!dev) if (!dev)
goto release; goto release;
} else } else
......
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