===== include/linux/netlink.h 1.15 vs edited ===== --- 1.15/include/linux/netlink.h 2004-04-17 02:24:35 +10:00 +++ edited/include/linux/netlink.h 2004-06-30 22:34:18 +10:00 @@ -90,6 +90,11 @@ #define NET_MAJOR 36 /* Major 36 is reserved for networking */ +enum { + NETLINK_UNCONNECTED = 0, + NETLINK_CONNECTED, +}; + #ifdef __KERNEL__ #include ===== net/netlink/af_netlink.c 1.48 vs edited ===== --- 1.48/net/netlink/af_netlink.c 2004-06-19 04:43:31 +10:00 +++ edited/net/netlink/af_netlink.c 2004-06-30 22:34:24 +10:00 @@ -365,6 +365,7 @@ struct sockaddr_nl *nladdr=(struct sockaddr_nl*)addr; if (addr->sa_family == AF_UNSPEC) { + sk->sk_state = NETLINK_UNCONNECTED; nlk->dst_pid = 0; nlk->dst_groups = 0; return 0; @@ -380,6 +381,7 @@ err = netlink_autobind(sock); if (err == 0) { + sk->sk_state = NETLINK_CONNECTED; nlk->dst_pid = nladdr->nl_pid; nlk->dst_groups = nladdr->nl_groups; } @@ -428,6 +430,12 @@ /* Don't bother queuing skb if kernel socket has no input function */ nlk = nlk_sk(sock); if (nlk->pid == 0 && !nlk->data_ready) { + sock_put(sock); + return ERR_PTR(-ECONNREFUSED); + } + + if (sock->sk_state == NETLINK_CONNECTED && + nlk->dst_pid != nlk_sk(ssk)->pid) { sock_put(sock); return ERR_PTR(-ECONNREFUSED); }