^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0-or-later
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * DECnet An implementation of the DECnet protocol suite for the LINUX
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * operating system. DECnet is implemented using the BSD Socket
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * interface as the means of communication with the user level.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * DECnet Network Services Protocol (Output)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) * Author: Eduardo Marcelo Serrat <emserrat@geocities.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) * Changes:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) * Steve Whitehouse: Split into dn_nsp_in.c and dn_nsp_out.c from
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) * original dn_nsp.c.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) * Steve Whitehouse: Updated to work with my new routing architecture.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) * Steve Whitehouse: Added changes from Eduardo Serrat's patches.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) * Steve Whitehouse: Now conninits have the "return" bit set.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) * Steve Whitehouse: Fixes to check alloc'd skbs are non NULL!
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) * Moved output state machine into one function
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) * Steve Whitehouse: New output state machine
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) * Paul Koning: Connect Confirm message fix.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) * Eduardo Serrat: Fix to stop dn_nsp_do_disc() sending malformed packets.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) * Steve Whitehouse: dn_nsp_output() and friends needed a spring clean
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) * Steve Whitehouse: Moved dn_nsp_send() in here from route.h
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) /******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) (c) 1995-1998 E.M. Serrat emserrat@geocities.com
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) *******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) #include <linux/errno.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) #include <linux/socket.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) #include <linux/in.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) #include <linux/timer.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) #include <linux/string.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) #include <linux/sockios.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) #include <linux/net.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) #include <linux/netdevice.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) #include <linux/inet.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) #include <linux/route.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) #include <net/sock.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) #include <linux/fcntl.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) #include <linux/mm.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) #include <linux/termios.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) #include <linux/interrupt.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) #include <linux/proc_fs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) #include <linux/stat.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) #include <linux/poll.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) #include <linux/if_packet.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) #include <net/neighbour.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) #include <net/dst.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) #include <net/flow.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) #include <net/dn.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) #include <net/dn_nsp.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) #include <net/dn_dev.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) #include <net/dn_route.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) static int nsp_backoff[NSP_MAXRXTSHIFT + 1] = { 1, 2, 4, 8, 16, 32, 64, 64, 64, 64, 64, 64, 64 };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) static void dn_nsp_send(struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) struct sock *sk = skb->sk;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) struct dn_scp *scp = DN_SK(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) struct dst_entry *dst;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) struct flowidn fld;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) skb_reset_transport_header(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) scp->stamp = jiffies;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) dst = sk_dst_check(sk, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) if (dst) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) try_again:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) skb_dst_set(skb, dst);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) dst_output(&init_net, skb->sk, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) memset(&fld, 0, sizeof(fld));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) fld.flowidn_oif = sk->sk_bound_dev_if;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) fld.saddr = dn_saddr2dn(&scp->addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) fld.daddr = dn_saddr2dn(&scp->peer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) dn_sk_ports_copy(&fld, scp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) fld.flowidn_proto = DNPROTO_NSP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) if (dn_route_output_sock(&sk->sk_dst_cache, &fld, sk, 0) == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) dst = sk_dst_get(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) sk->sk_route_caps = dst->dev->features;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) goto try_again;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) sk->sk_err = EHOSTUNREACH;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) if (!sock_flag(sk, SOCK_DEAD))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) sk->sk_state_change(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) * If sk == NULL, then we assume that we are supposed to be making
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) * a routing layer skb. If sk != NULL, then we are supposed to be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) * creating an skb for the NSP layer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) * The eventual aim is for each socket to have a cached header size
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) * for its outgoing packets, and to set hdr from this when sk != NULL.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) struct sk_buff *dn_alloc_skb(struct sock *sk, int size, gfp_t pri)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) struct sk_buff *skb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) int hdr = 64;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) if ((skb = alloc_skb(size + hdr, pri)) == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) skb->protocol = htons(ETH_P_DNA_RT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) skb->pkt_type = PACKET_OUTGOING;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) if (sk)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) skb_set_owner_w(skb, sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) skb_reserve(skb, hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) return skb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) * Calculate persist timer based upon the smoothed round
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) * trip time and the variance. Backoff according to the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) * nsp_backoff[] array.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) unsigned long dn_nsp_persist(struct sock *sk)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) struct dn_scp *scp = DN_SK(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) unsigned long t = ((scp->nsp_srtt >> 2) + scp->nsp_rttvar) >> 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) t *= nsp_backoff[scp->nsp_rxtshift];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) if (t < HZ) t = HZ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) if (t > (600*HZ)) t = (600*HZ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) if (scp->nsp_rxtshift < NSP_MAXRXTSHIFT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) scp->nsp_rxtshift++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) /* printk(KERN_DEBUG "rxtshift %lu, t=%lu\n", scp->nsp_rxtshift, t); */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) return t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) * This is called each time we get an estimate for the rtt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) * on the link.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) static void dn_nsp_rtt(struct sock *sk, long rtt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) struct dn_scp *scp = DN_SK(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) long srtt = (long)scp->nsp_srtt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) long rttvar = (long)scp->nsp_rttvar;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) long delta;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) * If the jiffies clock flips over in the middle of timestamp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) * gathering this value might turn out negative, so we make sure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) * that is it always positive here.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) if (rtt < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) rtt = -rtt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) * Add new rtt to smoothed average
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) delta = ((rtt << 3) - srtt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) srtt += (delta >> 3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) if (srtt >= 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) scp->nsp_srtt = (unsigned long)srtt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) scp->nsp_srtt = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) * Add new rtt varience to smoothed varience
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) delta >>= 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) rttvar += ((((delta>0)?(delta):(-delta)) - rttvar) >> 2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) if (rttvar >= 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) scp->nsp_rttvar = (unsigned long)rttvar;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) scp->nsp_rttvar = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) /* printk(KERN_DEBUG "srtt=%lu rttvar=%lu\n", scp->nsp_srtt, scp->nsp_rttvar); */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) * dn_nsp_clone_and_send - Send a data packet by cloning it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) * @skb: The packet to clone and transmit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) * @gfp: memory allocation flag
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) * Clone a queued data or other data packet and transmit it.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) * Returns: The number of times the packet has been sent previously
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) static inline unsigned int dn_nsp_clone_and_send(struct sk_buff *skb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) gfp_t gfp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) struct dn_skb_cb *cb = DN_SKB_CB(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) struct sk_buff *skb2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) int ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) if ((skb2 = skb_clone(skb, gfp)) != NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) ret = cb->xmit_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) cb->xmit_count++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) cb->stamp = jiffies;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) skb2->sk = skb->sk;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) dn_nsp_send(skb2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) * dn_nsp_output - Try and send something from socket queues
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) * @sk: The socket whose queues are to be investigated
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) * Try and send the packet on the end of the data and other data queues.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) * Other data gets priority over data, and if we retransmit a packet we
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) * reduce the window by dividing it in two.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) void dn_nsp_output(struct sock *sk)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) struct dn_scp *scp = DN_SK(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) struct sk_buff *skb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) unsigned int reduce_win = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) * First we check for otherdata/linkservice messages
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) if ((skb = skb_peek(&scp->other_xmit_queue)) != NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) reduce_win = dn_nsp_clone_and_send(skb, GFP_ATOMIC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) * If we may not send any data, we don't.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) * If we are still trying to get some other data down the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) * channel, we don't try and send any data.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) if (reduce_win || (scp->flowrem_sw != DN_SEND))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) goto recalc_window;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) if ((skb = skb_peek(&scp->data_xmit_queue)) != NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) reduce_win = dn_nsp_clone_and_send(skb, GFP_ATOMIC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) * If we've sent any frame more than once, we cut the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) * send window size in half. There is always a minimum
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) * window size of one available.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) recalc_window:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) if (reduce_win) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) scp->snd_window >>= 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) if (scp->snd_window < NSP_MIN_WINDOW)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) scp->snd_window = NSP_MIN_WINDOW;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) int dn_nsp_xmit_timeout(struct sock *sk)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) struct dn_scp *scp = DN_SK(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) dn_nsp_output(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) if (!skb_queue_empty(&scp->data_xmit_queue) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) !skb_queue_empty(&scp->other_xmit_queue))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) scp->persist = dn_nsp_persist(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) static inline __le16 *dn_mk_common_header(struct dn_scp *scp, struct sk_buff *skb, unsigned char msgflag, int len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) unsigned char *ptr = skb_push(skb, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) BUG_ON(len < 5);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) *ptr++ = msgflag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) *((__le16 *)ptr) = scp->addrrem;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) ptr += 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) *((__le16 *)ptr) = scp->addrloc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) ptr += 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) return (__le16 __force *)ptr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) static __le16 *dn_mk_ack_header(struct sock *sk, struct sk_buff *skb, unsigned char msgflag, int hlen, int other)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) struct dn_scp *scp = DN_SK(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) unsigned short acknum = scp->numdat_rcv & 0x0FFF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) unsigned short ackcrs = scp->numoth_rcv & 0x0FFF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) __le16 *ptr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) BUG_ON(hlen < 9);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) scp->ackxmt_dat = acknum;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) scp->ackxmt_oth = ackcrs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) acknum |= 0x8000;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) ackcrs |= 0x8000;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) /* If this is an "other data/ack" message, swap acknum and ackcrs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) if (other)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) swap(acknum, ackcrs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) /* Set "cross subchannel" bit in ackcrs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) ackcrs |= 0x2000;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) ptr = dn_mk_common_header(scp, skb, msgflag, hlen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) *ptr++ = cpu_to_le16(acknum);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) *ptr++ = cpu_to_le16(ackcrs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) return ptr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) static __le16 *dn_nsp_mk_data_header(struct sock *sk, struct sk_buff *skb, int oth)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) struct dn_scp *scp = DN_SK(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) struct dn_skb_cb *cb = DN_SKB_CB(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) __le16 *ptr = dn_mk_ack_header(sk, skb, cb->nsp_flags, 11, oth);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) if (unlikely(oth)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) cb->segnum = scp->numoth;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) seq_add(&scp->numoth, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) cb->segnum = scp->numdat;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) seq_add(&scp->numdat, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) *(ptr++) = cpu_to_le16(cb->segnum);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) return ptr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) void dn_nsp_queue_xmit(struct sock *sk, struct sk_buff *skb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) gfp_t gfp, int oth)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) struct dn_scp *scp = DN_SK(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) struct dn_skb_cb *cb = DN_SKB_CB(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) unsigned long t = ((scp->nsp_srtt >> 2) + scp->nsp_rttvar) >> 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) cb->xmit_count = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) dn_nsp_mk_data_header(sk, skb, oth);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) * Slow start: If we have been idle for more than
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) * one RTT, then reset window to min size.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) if ((jiffies - scp->stamp) > t)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) scp->snd_window = NSP_MIN_WINDOW;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) if (oth)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) skb_queue_tail(&scp->other_xmit_queue, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) skb_queue_tail(&scp->data_xmit_queue, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) if (scp->flowrem_sw != DN_SEND)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) dn_nsp_clone_and_send(skb, gfp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) int dn_nsp_check_xmit_queue(struct sock *sk, struct sk_buff *skb, struct sk_buff_head *q, unsigned short acknum)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) struct dn_skb_cb *cb = DN_SKB_CB(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) struct dn_scp *scp = DN_SK(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) struct sk_buff *skb2, *n, *ack = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) int wakeup = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) int try_retrans = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) unsigned long reftime = cb->stamp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) unsigned long pkttime;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) unsigned short xmit_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) unsigned short segnum;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) skb_queue_walk_safe(q, skb2, n) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) struct dn_skb_cb *cb2 = DN_SKB_CB(skb2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) if (dn_before_or_equal(cb2->segnum, acknum))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) ack = skb2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) /* printk(KERN_DEBUG "ack: %s %04x %04x\n", ack ? "ACK" : "SKIP", (int)cb2->segnum, (int)acknum); */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) if (ack == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) /* printk(KERN_DEBUG "check_xmit_queue: %04x, %d\n", acknum, cb2->xmit_count); */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) /* Does _last_ packet acked have xmit_count > 1 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) try_retrans = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) /* Remember to wake up the sending process */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) wakeup = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) /* Keep various statistics */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) pkttime = cb2->stamp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) xmit_count = cb2->xmit_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) segnum = cb2->segnum;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) /* Remove and drop ack'ed packet */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) skb_unlink(ack, q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) kfree_skb(ack);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) ack = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) * We don't expect to see acknowledgements for packets we
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) * haven't sent yet.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) WARN_ON(xmit_count == 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) * If the packet has only been sent once, we can use it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) * to calculate the RTT and also open the window a little
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) * further.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) if (xmit_count == 1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) if (dn_equal(segnum, acknum))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) dn_nsp_rtt(sk, (long)(pkttime - reftime));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) if (scp->snd_window < scp->max_window)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) scp->snd_window++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) * Packet has been sent more than once. If this is the last
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) * packet to be acknowledged then we want to send the next
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) * packet in the send queue again (assumes the remote host does
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) * go-back-N error control).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) if (xmit_count > 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) try_retrans = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) if (try_retrans)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) dn_nsp_output(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) return wakeup;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) void dn_nsp_send_data_ack(struct sock *sk)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) struct sk_buff *skb = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) if ((skb = dn_alloc_skb(sk, 9, GFP_ATOMIC)) == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) skb_reserve(skb, 9);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) dn_mk_ack_header(sk, skb, 0x04, 9, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) dn_nsp_send(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) void dn_nsp_send_oth_ack(struct sock *sk)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) struct sk_buff *skb = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) if ((skb = dn_alloc_skb(sk, 9, GFP_ATOMIC)) == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) skb_reserve(skb, 9);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) dn_mk_ack_header(sk, skb, 0x14, 9, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) dn_nsp_send(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) void dn_send_conn_ack (struct sock *sk)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) struct dn_scp *scp = DN_SK(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) struct sk_buff *skb = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) struct nsp_conn_ack_msg *msg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) if ((skb = dn_alloc_skb(sk, 3, sk->sk_allocation)) == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) msg = skb_put(skb, 3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) msg->msgflg = 0x24;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) msg->dstaddr = scp->addrrem;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) dn_nsp_send(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) static int dn_nsp_retrans_conn_conf(struct sock *sk)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) struct dn_scp *scp = DN_SK(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) if (scp->state == DN_CC)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) dn_send_conn_conf(sk, GFP_ATOMIC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) void dn_send_conn_conf(struct sock *sk, gfp_t gfp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) struct dn_scp *scp = DN_SK(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) struct sk_buff *skb = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) struct nsp_conn_init_msg *msg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) __u8 len = (__u8)le16_to_cpu(scp->conndata_out.opt_optl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) if ((skb = dn_alloc_skb(sk, 50 + len, gfp)) == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) msg = skb_put(skb, sizeof(*msg));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) msg->msgflg = 0x28;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) msg->dstaddr = scp->addrrem;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) msg->srcaddr = scp->addrloc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) msg->services = scp->services_loc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) msg->info = scp->info_loc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) msg->segsize = cpu_to_le16(scp->segsize_loc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) skb_put_u8(skb, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) if (len > 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) skb_put_data(skb, scp->conndata_out.opt_data, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) dn_nsp_send(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) scp->persist = dn_nsp_persist(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) scp->persist_fxn = dn_nsp_retrans_conn_conf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) static __inline__ void dn_nsp_do_disc(struct sock *sk, unsigned char msgflg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) unsigned short reason, gfp_t gfp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) struct dst_entry *dst,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) int ddl, unsigned char *dd, __le16 rem, __le16 loc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) struct sk_buff *skb = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) int size = 7 + ddl + ((msgflg == NSP_DISCINIT) ? 1 : 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) unsigned char *msg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) if ((dst == NULL) || (rem == 0)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) net_dbg_ratelimited("DECnet: dn_nsp_do_disc: BUG! Please report this to SteveW@ACM.org rem=%u dst=%p\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) le16_to_cpu(rem), dst);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) if ((skb = dn_alloc_skb(sk, size, gfp)) == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) msg = skb_put(skb, size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) *msg++ = msgflg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) *(__le16 *)msg = rem;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) msg += 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) *(__le16 *)msg = loc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) msg += 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) *(__le16 *)msg = cpu_to_le16(reason);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) msg += 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550) if (msgflg == NSP_DISCINIT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) *msg++ = ddl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) if (ddl) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) memcpy(msg, dd, ddl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) * This doesn't go via the dn_nsp_send() function since we need
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) * to be able to send disc packets out which have no socket
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560) * associations.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) skb_dst_set(skb, dst_clone(dst));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563) dst_output(&init_net, skb->sk, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567) void dn_nsp_send_disc(struct sock *sk, unsigned char msgflg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568) unsigned short reason, gfp_t gfp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570) struct dn_scp *scp = DN_SK(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571) int ddl = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573) if (msgflg == NSP_DISCINIT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574) ddl = le16_to_cpu(scp->discdata_out.opt_optl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576) if (reason == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577) reason = le16_to_cpu(scp->discdata_out.opt_status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579) dn_nsp_do_disc(sk, msgflg, reason, gfp, __sk_dst_get(sk), ddl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580) scp->discdata_out.opt_data, scp->addrrem, scp->addrloc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584) void dn_nsp_return_disc(struct sk_buff *skb, unsigned char msgflg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585) unsigned short reason)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587) struct dn_skb_cb *cb = DN_SKB_CB(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588) int ddl = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589) gfp_t gfp = GFP_ATOMIC;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591) dn_nsp_do_disc(NULL, msgflg, reason, gfp, skb_dst(skb), ddl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592) NULL, cb->src_port, cb->dst_port);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596) void dn_nsp_send_link(struct sock *sk, unsigned char lsflags, char fcval)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598) struct dn_scp *scp = DN_SK(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599) struct sk_buff *skb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600) unsigned char *ptr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601) gfp_t gfp = GFP_ATOMIC;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603) if ((skb = dn_alloc_skb(sk, DN_MAX_NSP_DATA_HEADER + 2, gfp)) == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606) skb_reserve(skb, DN_MAX_NSP_DATA_HEADER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607) ptr = skb_put(skb, 2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608) DN_SKB_CB(skb)->nsp_flags = 0x10;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609) *ptr++ = lsflags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610) *ptr = fcval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612) dn_nsp_queue_xmit(sk, skb, gfp, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614) scp->persist = dn_nsp_persist(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615) scp->persist_fxn = dn_nsp_xmit_timeout;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618) static int dn_nsp_retrans_conninit(struct sock *sk)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620) struct dn_scp *scp = DN_SK(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622) if (scp->state == DN_CI)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623) dn_nsp_send_conninit(sk, NSP_RCI);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628) void dn_nsp_send_conninit(struct sock *sk, unsigned char msgflg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630) struct dn_scp *scp = DN_SK(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631) struct nsp_conn_init_msg *msg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632) unsigned char aux;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633) unsigned char menuver;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 634) struct dn_skb_cb *cb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 635) unsigned char type = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 636) gfp_t allocation = (msgflg == NSP_CI) ? sk->sk_allocation : GFP_ATOMIC;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637) struct sk_buff *skb = dn_alloc_skb(sk, 200, allocation);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 638)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 639) if (!skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 640) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 641)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 642) cb = DN_SKB_CB(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 643) msg = skb_put(skb, sizeof(*msg));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 644)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 645) msg->msgflg = msgflg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 646) msg->dstaddr = 0x0000; /* Remote Node will assign it*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 647)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 648) msg->srcaddr = scp->addrloc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 649) msg->services = scp->services_loc; /* Requested flow control */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 650) msg->info = scp->info_loc; /* Version Number */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 651) msg->segsize = cpu_to_le16(scp->segsize_loc); /* Max segment size */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 652)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 653) if (scp->peer.sdn_objnum)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 654) type = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 655)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 656) skb_put(skb, dn_sockaddr2username(&scp->peer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 657) skb_tail_pointer(skb), type));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 658) skb_put(skb, dn_sockaddr2username(&scp->addr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 659) skb_tail_pointer(skb), 2));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 660)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 661) menuver = DN_MENUVER_ACC | DN_MENUVER_USR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 662) if (scp->peer.sdn_flags & SDF_PROXY)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 663) menuver |= DN_MENUVER_PRX;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 664) if (scp->peer.sdn_flags & SDF_UICPROXY)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 665) menuver |= DN_MENUVER_UIC;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 666)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 667) skb_put_u8(skb, menuver); /* Menu Version */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 668)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 669) aux = scp->accessdata.acc_userl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 670) skb_put_u8(skb, aux);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 671) if (aux > 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 672) skb_put_data(skb, scp->accessdata.acc_user, aux);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 673)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 674) aux = scp->accessdata.acc_passl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 675) skb_put_u8(skb, aux);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 676) if (aux > 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 677) skb_put_data(skb, scp->accessdata.acc_pass, aux);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 678)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 679) aux = scp->accessdata.acc_accl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 680) skb_put_u8(skb, aux);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 681) if (aux > 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 682) skb_put_data(skb, scp->accessdata.acc_acc, aux);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 683)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 684) aux = (__u8)le16_to_cpu(scp->conndata_out.opt_optl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 685) skb_put_u8(skb, aux);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 686) if (aux > 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 687) skb_put_data(skb, scp->conndata_out.opt_data, aux);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 688)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 689) scp->persist = dn_nsp_persist(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 690) scp->persist_fxn = dn_nsp_retrans_conninit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 691)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 692) cb->rt_flags = DN_RT_F_RQR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 693)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 694) dn_nsp_send(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 695) }