^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /* net/atm/clip.c - RFC1577 Classical IP over ATM */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) /* Written 1995-2000 by Werner Almesberger, EPFL LRC/ICA */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) #define pr_fmt(fmt) KBUILD_MODNAME ":%s: " fmt, __func__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #include <linux/string.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #include <linux/errno.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/kernel.h> /* for UINT_MAX */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <linux/netdevice.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <linux/skbuff.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <linux/wait.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include <linux/timer.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include <linux/if_arp.h> /* for some manifest constants */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #include <linux/notifier.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #include <linux/atm.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #include <linux/atmdev.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #include <linux/atmclip.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #include <linux/atmarp.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) #include <linux/capability.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) #include <linux/ip.h> /* for net/route.h */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) #include <linux/in.h> /* for struct sockaddr_in */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) #include <linux/if.h> /* for IFF_UP */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) #include <linux/inetdevice.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) #include <linux/bitops.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) #include <linux/poison.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) #include <linux/proc_fs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) #include <linux/seq_file.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) #include <linux/rcupdate.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) #include <linux/jhash.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) #include <net/route.h> /* for struct rtable and routing */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) #include <net/icmp.h> /* icmp_send */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) #include <net/arp.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) #include <linux/param.h> /* for HZ */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) #include <linux/uaccess.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) #include <asm/byteorder.h> /* for htons etc. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) #include <linux/atomic.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) #include "common.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) #include "resources.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) #include <net/atmclip.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) static struct net_device *clip_devs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) static struct atm_vcc *atmarpd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) static struct timer_list idle_timer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) static const struct neigh_ops clip_neigh_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) static int to_atmarpd(enum atmarp_ctrl_type type, int itf, __be32 ip)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) struct sock *sk;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) struct atmarp_ctrl *ctrl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) struct sk_buff *skb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) pr_debug("(%d)\n", type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) if (!atmarpd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) return -EUNATCH;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) skb = alloc_skb(sizeof(struct atmarp_ctrl), GFP_ATOMIC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) if (!skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) ctrl = skb_put(skb, sizeof(struct atmarp_ctrl));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) ctrl->type = type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) ctrl->itf_num = itf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) ctrl->ip = ip;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) atm_force_charge(atmarpd, skb->truesize);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) sk = sk_atm(atmarpd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) skb_queue_tail(&sk->sk_receive_queue, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) sk->sk_data_ready(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) static void link_vcc(struct clip_vcc *clip_vcc, struct atmarp_entry *entry)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) pr_debug("%p to entry %p (neigh %p)\n", clip_vcc, entry, entry->neigh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) clip_vcc->entry = entry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) clip_vcc->xoff = 0; /* @@@ may overrun buffer by one packet */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) clip_vcc->next = entry->vccs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) entry->vccs = clip_vcc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) entry->neigh->used = jiffies;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) static void unlink_clip_vcc(struct clip_vcc *clip_vcc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) struct atmarp_entry *entry = clip_vcc->entry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) struct clip_vcc **walk;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) if (!entry) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) pr_err("!clip_vcc->entry (clip_vcc %p)\n", clip_vcc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) netif_tx_lock_bh(entry->neigh->dev); /* block clip_start_xmit() */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) entry->neigh->used = jiffies;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) for (walk = &entry->vccs; *walk; walk = &(*walk)->next)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) if (*walk == clip_vcc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) int error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) *walk = clip_vcc->next; /* atomic */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) clip_vcc->entry = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) if (clip_vcc->xoff)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) netif_wake_queue(entry->neigh->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) if (entry->vccs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) entry->expires = jiffies - 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) /* force resolution or expiration */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) error = neigh_update(entry->neigh, NULL, NUD_NONE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) NEIGH_UPDATE_F_ADMIN, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) pr_err("neigh_update failed with %d\n", error);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) pr_err("ATMARP: failed (entry %p, vcc 0x%p)\n", entry, clip_vcc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) netif_tx_unlock_bh(entry->neigh->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) /* The neighbour entry n->lock is held. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) static int neigh_check_cb(struct neighbour *n)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) struct atmarp_entry *entry = neighbour_priv(n);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) struct clip_vcc *cv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) if (n->ops != &clip_neigh_ops)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) for (cv = entry->vccs; cv; cv = cv->next) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) unsigned long exp = cv->last_use + cv->idle_timeout;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) if (cv->idle_timeout && time_after(jiffies, exp)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) pr_debug("releasing vcc %p->%p of entry %p\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) cv, cv->vcc, entry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) vcc_release_async(cv->vcc, -ETIMEDOUT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) if (entry->vccs || time_before(jiffies, entry->expires))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) if (refcount_read(&n->refcnt) > 1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) struct sk_buff *skb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) pr_debug("destruction postponed with ref %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) refcount_read(&n->refcnt));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) while ((skb = skb_dequeue(&n->arp_queue)) != NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) dev_kfree_skb(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) return 0;
^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) pr_debug("expired neigh %p\n", n);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) static void idle_timer_check(struct timer_list *unused)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) write_lock(&arp_tbl.lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) __neigh_for_each_release(&arp_tbl, neigh_check_cb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) mod_timer(&idle_timer, jiffies + CLIP_CHECK_INTERVAL * HZ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) write_unlock(&arp_tbl.lock);
^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) static int clip_arp_rcv(struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) struct atm_vcc *vcc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) pr_debug("\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) vcc = ATM_SKB(skb)->vcc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) if (!vcc || !atm_charge(vcc, skb->truesize)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) dev_kfree_skb_any(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) pr_debug("pushing to %p\n", vcc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) pr_debug("using %p\n", CLIP_VCC(vcc)->old_push);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) CLIP_VCC(vcc)->old_push(vcc, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) static const unsigned char llc_oui[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 0xaa, /* DSAP: non-ISO */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 0xaa, /* SSAP: non-ISO */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 0x03, /* Ctrl: Unnumbered Information Command PDU */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 0x00, /* OUI: EtherType */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 0x00,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 0x00
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) static void clip_push(struct atm_vcc *vcc, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) struct clip_vcc *clip_vcc = CLIP_VCC(vcc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) pr_debug("\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) if (!clip_devs) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) atm_return(vcc, skb->truesize);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) kfree_skb(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) if (!skb) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) pr_debug("removing VCC %p\n", clip_vcc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) if (clip_vcc->entry)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) unlink_clip_vcc(clip_vcc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) clip_vcc->old_push(vcc, NULL); /* pass on the bad news */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) kfree(clip_vcc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) atm_return(vcc, skb->truesize);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) skb->dev = clip_vcc->entry ? clip_vcc->entry->neigh->dev : clip_devs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) /* clip_vcc->entry == NULL if we don't have an IP address yet */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) if (!skb->dev) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) dev_kfree_skb_any(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) ATM_SKB(skb)->vcc = vcc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) skb_reset_mac_header(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) if (!clip_vcc->encap ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) skb->len < RFC1483LLC_LEN ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) memcmp(skb->data, llc_oui, sizeof(llc_oui)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) skb->protocol = htons(ETH_P_IP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) skb->protocol = ((__be16 *)skb->data)[3];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) skb_pull(skb, RFC1483LLC_LEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) if (skb->protocol == htons(ETH_P_ARP)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) skb->dev->stats.rx_packets++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) skb->dev->stats.rx_bytes += skb->len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) clip_arp_rcv(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) clip_vcc->last_use = jiffies;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) skb->dev->stats.rx_packets++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) skb->dev->stats.rx_bytes += skb->len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) memset(ATM_SKB(skb), 0, sizeof(struct atm_skb_data));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) netif_rx(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) * Note: these spinlocks _must_not_ block on non-SMP. The only goal is that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) * clip_pop is atomic with respect to the critical section in clip_start_xmit.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) static void clip_pop(struct atm_vcc *vcc, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) struct clip_vcc *clip_vcc = CLIP_VCC(vcc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) struct net_device *dev = skb->dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) int old;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) pr_debug("(vcc %p)\n", vcc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) clip_vcc->old_pop(vcc, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) /* skb->dev == NULL in outbound ARP packets */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) if (!dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) spin_lock_irqsave(&PRIV(dev)->xoff_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) if (atm_may_send(vcc, 0)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) old = xchg(&clip_vcc->xoff, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) if (old)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) netif_wake_queue(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) spin_unlock_irqrestore(&PRIV(dev)->xoff_lock, flags);
^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) static void clip_neigh_solicit(struct neighbour *neigh, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) __be32 *ip = (__be32 *) neigh->primary_key;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) pr_debug("(neigh %p, skb %p)\n", neigh, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) to_atmarpd(act_need, PRIV(neigh->dev)->number, *ip);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) static void clip_neigh_error(struct neighbour *neigh, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) #ifndef CONFIG_ATM_CLIP_NO_ICMP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) icmp_send(skb, ICMP_DEST_UNREACH, ICMP_HOST_UNREACH, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) kfree_skb(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) static const struct neigh_ops clip_neigh_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) .family = AF_INET,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) .solicit = clip_neigh_solicit,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) .error_report = clip_neigh_error,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) .output = neigh_direct_output,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) .connected_output = neigh_direct_output,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) static int clip_constructor(struct net_device *dev, struct neighbour *neigh)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) struct atmarp_entry *entry = neighbour_priv(neigh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) if (neigh->tbl->family != AF_INET)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) if (neigh->type != RTN_UNICAST)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) neigh->nud_state = NUD_NONE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) neigh->ops = &clip_neigh_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) neigh->output = neigh->ops->output;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) entry->neigh = neigh;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) entry->vccs = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) entry->expires = jiffies - 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) /* @@@ copy bh locking from arp.c -- need to bh-enable atm code before */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) * We play with the resolve flag: 0 and 1 have the usual meaning, but -1 means
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) * to allocate the neighbour entry but not to ask atmarpd for resolution. Also,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) * don't increment the usage count. This is used to create entries in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) * clip_setentry.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) static int clip_encap(struct atm_vcc *vcc, int mode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) if (!CLIP_VCC(vcc))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) return -EBADFD;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) CLIP_VCC(vcc)->encap = mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) static netdev_tx_t clip_start_xmit(struct sk_buff *skb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) struct net_device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) struct clip_priv *clip_priv = PRIV(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) struct dst_entry *dst = skb_dst(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) struct atmarp_entry *entry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) struct neighbour *n;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) struct atm_vcc *vcc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) struct rtable *rt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) __be32 *daddr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) int old;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) pr_debug("(skb %p)\n", skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) if (!dst) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) pr_err("skb_dst(skb) == NULL\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) dev_kfree_skb(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) dev->stats.tx_dropped++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) return NETDEV_TX_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) rt = (struct rtable *) dst;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) if (rt->rt_gw_family == AF_INET)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) daddr = &rt->rt_gw4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) daddr = &ip_hdr(skb)->daddr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) n = dst_neigh_lookup(dst, daddr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) if (!n) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) pr_err("NO NEIGHBOUR !\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) dev_kfree_skb(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) dev->stats.tx_dropped++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) return NETDEV_TX_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) entry = neighbour_priv(n);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) if (!entry->vccs) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) if (time_after(jiffies, entry->expires)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) /* should be resolved */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) entry->expires = jiffies + ATMARP_RETRY_DELAY * HZ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) to_atmarpd(act_need, PRIV(dev)->number, *((__be32 *)n->primary_key));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) if (entry->neigh->arp_queue.qlen < ATMARP_MAX_UNRES_PACKETS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) skb_queue_tail(&entry->neigh->arp_queue, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) dev_kfree_skb(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) dev->stats.tx_dropped++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) goto out_release_neigh;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) pr_debug("neigh %p, vccs %p\n", entry, entry->vccs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) ATM_SKB(skb)->vcc = vcc = entry->vccs->vcc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) pr_debug("using neighbour %p, vcc %p\n", n, vcc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) if (entry->vccs->encap) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) void *here;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) here = skb_push(skb, RFC1483LLC_LEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) memcpy(here, llc_oui, sizeof(llc_oui));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) ((__be16 *) here)[3] = skb->protocol;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) atm_account_tx(vcc, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) entry->vccs->last_use = jiffies;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) pr_debug("atm_skb(%p)->vcc(%p)->dev(%p)\n", skb, vcc, vcc->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) old = xchg(&entry->vccs->xoff, 1); /* assume XOFF ... */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) if (old) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) pr_warn("XOFF->XOFF transition\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) goto out_release_neigh;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) dev->stats.tx_packets++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) dev->stats.tx_bytes += skb->len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) vcc->send(vcc, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) if (atm_may_send(vcc, 0)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) entry->vccs->xoff = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) goto out_release_neigh;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) spin_lock_irqsave(&clip_priv->xoff_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) netif_stop_queue(dev); /* XOFF -> throttle immediately */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) barrier();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) if (!entry->vccs->xoff)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) netif_start_queue(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) /* Oh, we just raced with clip_pop. netif_start_queue should be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) good enough, because nothing should really be asleep because
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) of the brief netif_stop_queue. If this isn't true or if it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) changes, use netif_wake_queue instead. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) spin_unlock_irqrestore(&clip_priv->xoff_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) out_release_neigh:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) neigh_release(n);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) return NETDEV_TX_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) static int clip_mkip(struct atm_vcc *vcc, int timeout)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) struct clip_vcc *clip_vcc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) if (!vcc->push)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) return -EBADFD;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) clip_vcc = kmalloc(sizeof(struct clip_vcc), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) if (!clip_vcc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) pr_debug("%p vcc %p\n", clip_vcc, vcc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) clip_vcc->vcc = vcc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) vcc->user_back = clip_vcc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) set_bit(ATM_VF_IS_CLIP, &vcc->flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) clip_vcc->entry = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) clip_vcc->xoff = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) clip_vcc->encap = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) clip_vcc->last_use = jiffies;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) clip_vcc->idle_timeout = timeout * HZ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) clip_vcc->old_push = vcc->push;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) clip_vcc->old_pop = vcc->pop;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) vcc->push = clip_push;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) vcc->pop = clip_pop;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) /* re-process everything received between connection setup and MKIP */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) vcc_process_recv_queue(vcc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) static int clip_setentry(struct atm_vcc *vcc, __be32 ip)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) struct neighbour *neigh;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) struct atmarp_entry *entry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) int error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) struct clip_vcc *clip_vcc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) struct rtable *rt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) if (vcc->push != clip_push) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) pr_warn("non-CLIP VCC\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) return -EBADF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) clip_vcc = CLIP_VCC(vcc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) if (!ip) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) if (!clip_vcc->entry) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) pr_err("hiding hidden ATMARP entry\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) pr_debug("remove\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) unlink_clip_vcc(clip_vcc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) rt = ip_route_output(&init_net, ip, 0, 1, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) if (IS_ERR(rt))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) return PTR_ERR(rt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) neigh = __neigh_lookup(&arp_tbl, &ip, rt->dst.dev, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) ip_rt_put(rt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) if (!neigh)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) entry = neighbour_priv(neigh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) if (entry != clip_vcc->entry) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) if (!clip_vcc->entry)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) pr_debug("add\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) pr_debug("update\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) unlink_clip_vcc(clip_vcc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) link_vcc(clip_vcc, entry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) error = neigh_update(neigh, llc_oui, NUD_PERMANENT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) NEIGH_UPDATE_F_OVERRIDE | NEIGH_UPDATE_F_ADMIN, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) neigh_release(neigh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) static const struct net_device_ops clip_netdev_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) .ndo_start_xmit = clip_start_xmit,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) .ndo_neigh_construct = clip_constructor,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) static void clip_setup(struct net_device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) dev->netdev_ops = &clip_netdev_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) dev->type = ARPHRD_ATM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) dev->neigh_priv_len = sizeof(struct atmarp_entry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) dev->hard_header_len = RFC1483LLC_LEN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) dev->mtu = RFC1626_MTU;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) dev->tx_queue_len = 100; /* "normal" queue (packets) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) /* When using a "real" qdisc, the qdisc determines the queue */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) /* length. tx_queue_len is only used for the default case, */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) /* without any more elaborate queuing. 100 is a reasonable */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) /* compromise between decent burst-tolerance and protection */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) /* against memory hogs. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) netif_keep_dst(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) static int clip_create(int number)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) struct net_device *dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) struct clip_priv *clip_priv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) int error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) if (number != -1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) for (dev = clip_devs; dev; dev = PRIV(dev)->next)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) if (PRIV(dev)->number == number)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) return -EEXIST;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) number = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) for (dev = clip_devs; dev; dev = PRIV(dev)->next)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) if (PRIV(dev)->number >= number)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) number = PRIV(dev)->number + 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) dev = alloc_netdev(sizeof(struct clip_priv), "", NET_NAME_UNKNOWN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) clip_setup);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) if (!dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) clip_priv = PRIV(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) sprintf(dev->name, "atm%d", number);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) spin_lock_init(&clip_priv->xoff_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) clip_priv->number = number;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) error = register_netdev(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) if (error) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) free_netdev(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) clip_priv->next = clip_devs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540) clip_devs = dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541) pr_debug("registered (net:%s)\n", dev->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) return number;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) static int clip_device_event(struct notifier_block *this, unsigned long event,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) void *ptr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) struct net_device *dev = netdev_notifier_info_to_dev(ptr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550) if (!net_eq(dev_net(dev), &init_net))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) return NOTIFY_DONE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) if (event == NETDEV_UNREGISTER)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) return NOTIFY_DONE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) /* ignore non-CLIP devices */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) if (dev->type != ARPHRD_ATM || dev->netdev_ops != &clip_netdev_ops)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) return NOTIFY_DONE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560) switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561) case NETDEV_UP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) pr_debug("NETDEV_UP\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563) to_atmarpd(act_up, PRIV(dev)->number, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565) case NETDEV_GOING_DOWN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566) pr_debug("NETDEV_DOWN\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567) to_atmarpd(act_down, PRIV(dev)->number, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569) case NETDEV_CHANGE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570) case NETDEV_CHANGEMTU:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571) pr_debug("NETDEV_CHANGE*\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572) to_atmarpd(act_change, PRIV(dev)->number, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575) return NOTIFY_DONE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578) static int clip_inet_event(struct notifier_block *this, unsigned long event,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579) void *ifa)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581) struct in_device *in_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582) struct netdev_notifier_info info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584) in_dev = ((struct in_ifaddr *)ifa)->ifa_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586) * Transitions are of the down-change-up type, so it's sufficient to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587) * handle the change on up.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589) if (event != NETDEV_UP)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590) return NOTIFY_DONE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591) netdev_notifier_info_init(&info, in_dev->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592) return clip_device_event(this, NETDEV_CHANGE, &info);
^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) static struct notifier_block clip_dev_notifier = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596) .notifier_call = clip_device_event,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601) static struct notifier_block clip_inet_notifier = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602) .notifier_call = clip_inet_event,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607) static void atmarpd_close(struct atm_vcc *vcc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609) pr_debug("\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611) rtnl_lock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612) atmarpd = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613) skb_queue_purge(&sk_atm(vcc)->sk_receive_queue);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614) rtnl_unlock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616) pr_debug("(done)\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617) module_put(THIS_MODULE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620) static const struct atmdev_ops atmarpd_dev_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621) .close = atmarpd_close
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625) static struct atm_dev atmarpd_dev = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626) .ops = &atmarpd_dev_ops,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627) .type = "arpd",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628) .number = 999,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629) .lock = __SPIN_LOCK_UNLOCKED(atmarpd_dev.lock)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633) static int atm_init_atmarp(struct atm_vcc *vcc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 634) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 635) rtnl_lock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 636) if (atmarpd) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637) rtnl_unlock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 638) return -EADDRINUSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 639) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 640)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 641) mod_timer(&idle_timer, jiffies + CLIP_CHECK_INTERVAL * HZ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 642)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 643) atmarpd = vcc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 644) set_bit(ATM_VF_META, &vcc->flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 645) set_bit(ATM_VF_READY, &vcc->flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 646) /* allow replies and avoid getting closed if signaling dies */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 647) vcc->dev = &atmarpd_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 648) vcc_insert_socket(sk_atm(vcc));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 649) vcc->push = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 650) vcc->pop = NULL; /* crash */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 651) vcc->push_oam = NULL; /* crash */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 652) rtnl_unlock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 653) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 654) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 655)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 656) static int clip_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 657) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 658) struct atm_vcc *vcc = ATM_SD(sock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 659) int err = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 660)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 661) switch (cmd) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 662) case SIOCMKCLIP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 663) case ATMARPD_CTRL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 664) case ATMARP_MKIP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 665) case ATMARP_SETENTRY:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 666) case ATMARP_ENCAP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 667) if (!capable(CAP_NET_ADMIN))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 668) return -EPERM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 669) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 670) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 671) return -ENOIOCTLCMD;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 672) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 673)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 674) switch (cmd) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 675) case SIOCMKCLIP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 676) err = clip_create(arg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 677) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 678) case ATMARPD_CTRL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 679) err = atm_init_atmarp(vcc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 680) if (!err) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 681) sock->state = SS_CONNECTED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 682) __module_get(THIS_MODULE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 683) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 684) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 685) case ATMARP_MKIP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 686) err = clip_mkip(vcc, arg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 687) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 688) case ATMARP_SETENTRY:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 689) err = clip_setentry(vcc, (__force __be32)arg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 690) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 691) case ATMARP_ENCAP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 692) err = clip_encap(vcc, arg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 693) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 694) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 695) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 696) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 697)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 698) static struct atm_ioctl clip_ioctl_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 699) .owner = THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 700) .ioctl = clip_ioctl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 701) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 702)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 703) #ifdef CONFIG_PROC_FS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 704)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 705) static void svc_addr(struct seq_file *seq, struct sockaddr_atmsvc *addr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 706) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 707) static int code[] = { 1, 2, 10, 6, 1, 0 };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 708) static int e164[] = { 1, 8, 4, 6, 1, 0 };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 709)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 710) if (*addr->sas_addr.pub) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 711) seq_printf(seq, "%s", addr->sas_addr.pub);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 712) if (*addr->sas_addr.prv)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 713) seq_putc(seq, '+');
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 714) } else if (!*addr->sas_addr.prv) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 715) seq_printf(seq, "%s", "(none)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 716) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 717) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 718) if (*addr->sas_addr.prv) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 719) unsigned char *prv = addr->sas_addr.prv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 720) int *fields;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 721) int i, j;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 722)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 723) fields = *prv == ATM_AFI_E164 ? e164 : code;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 724) for (i = 0; fields[i]; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 725) for (j = fields[i]; j; j--)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 726) seq_printf(seq, "%02X", *prv++);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 727) if (fields[i + 1])
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 728) seq_putc(seq, '.');
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 729) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 730) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 731) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 732)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 733) /* This means the neighbour entry has no attached VCC objects. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 734) #define SEQ_NO_VCC_TOKEN ((void *) 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 735)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 736) static void atmarp_info(struct seq_file *seq, struct neighbour *n,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 737) struct atmarp_entry *entry, struct clip_vcc *clip_vcc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 738) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 739) struct net_device *dev = n->dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 740) unsigned long exp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 741) char buf[17];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 742) int svc, llc, off;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 743)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 744) svc = ((clip_vcc == SEQ_NO_VCC_TOKEN) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 745) (sk_atm(clip_vcc->vcc)->sk_family == AF_ATMSVC));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 746)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 747) llc = ((clip_vcc == SEQ_NO_VCC_TOKEN) || clip_vcc->encap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 748)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 749) if (clip_vcc == SEQ_NO_VCC_TOKEN)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 750) exp = entry->neigh->used;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 751) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 752) exp = clip_vcc->last_use;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 753)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 754) exp = (jiffies - exp) / HZ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 755)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 756) seq_printf(seq, "%-6s%-4s%-4s%5ld ",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 757) dev->name, svc ? "SVC" : "PVC", llc ? "LLC" : "NULL", exp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 758)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 759) off = scnprintf(buf, sizeof(buf) - 1, "%pI4", n->primary_key);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 760) while (off < 16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 761) buf[off++] = ' ';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 762) buf[off] = '\0';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 763) seq_printf(seq, "%s", buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 764)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 765) if (clip_vcc == SEQ_NO_VCC_TOKEN) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 766) if (time_before(jiffies, entry->expires))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 767) seq_printf(seq, "(resolving)\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 768) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 769) seq_printf(seq, "(expired, ref %d)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 770) refcount_read(&entry->neigh->refcnt));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 771) } else if (!svc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 772) seq_printf(seq, "%d.%d.%d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 773) clip_vcc->vcc->dev->number,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 774) clip_vcc->vcc->vpi, clip_vcc->vcc->vci);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 775) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 776) svc_addr(seq, &clip_vcc->vcc->remote);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 777) seq_putc(seq, '\n');
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 778) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 779) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 780)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 781) struct clip_seq_state {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 782) /* This member must be first. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 783) struct neigh_seq_state ns;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 784)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 785) /* Local to clip specific iteration. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 786) struct clip_vcc *vcc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 787) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 788)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 789) static struct clip_vcc *clip_seq_next_vcc(struct atmarp_entry *e,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 790) struct clip_vcc *curr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 791) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 792) if (!curr) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 793) curr = e->vccs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 794) if (!curr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 795) return SEQ_NO_VCC_TOKEN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 796) return curr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 797) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 798) if (curr == SEQ_NO_VCC_TOKEN)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 799) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 800)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 801) curr = curr->next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 802)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 803) return curr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 804) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 805)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 806) static void *clip_seq_vcc_walk(struct clip_seq_state *state,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 807) struct atmarp_entry *e, loff_t * pos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 808) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 809) struct clip_vcc *vcc = state->vcc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 810)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 811) vcc = clip_seq_next_vcc(e, vcc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 812) if (vcc && pos != NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 813) while (*pos) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 814) vcc = clip_seq_next_vcc(e, vcc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 815) if (!vcc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 816) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 817) --(*pos);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 818) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 819) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 820) state->vcc = vcc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 821)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 822) return vcc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 823) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 824)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 825) static void *clip_seq_sub_iter(struct neigh_seq_state *_state,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 826) struct neighbour *n, loff_t * pos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 827) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 828) struct clip_seq_state *state = (struct clip_seq_state *)_state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 829)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 830) if (n->dev->type != ARPHRD_ATM)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 831) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 832)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 833) return clip_seq_vcc_walk(state, neighbour_priv(n), pos);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 834) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 835)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 836) static void *clip_seq_start(struct seq_file *seq, loff_t * pos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 837) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 838) struct clip_seq_state *state = seq->private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 839) state->ns.neigh_sub_iter = clip_seq_sub_iter;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 840) return neigh_seq_start(seq, pos, &arp_tbl, NEIGH_SEQ_NEIGH_ONLY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 841) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 842)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 843) static int clip_seq_show(struct seq_file *seq, void *v)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 844) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 845) static char atm_arp_banner[] =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 846) "IPitf TypeEncp Idle IP address ATM address\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 847)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 848) if (v == SEQ_START_TOKEN) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 849) seq_puts(seq, atm_arp_banner);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 850) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 851) struct clip_seq_state *state = seq->private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 852) struct clip_vcc *vcc = state->vcc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 853) struct neighbour *n = v;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 854)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 855) atmarp_info(seq, n, neighbour_priv(n), vcc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 856) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 857) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 858) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 859)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 860) static const struct seq_operations arp_seq_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 861) .start = clip_seq_start,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 862) .next = neigh_seq_next,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 863) .stop = neigh_seq_stop,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 864) .show = clip_seq_show,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 865) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 866) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 867)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 868) static void atm_clip_exit_noproc(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 869)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 870) static int __init atm_clip_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 871) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 872) register_atm_ioctl(&clip_ioctl_ops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 873) register_netdevice_notifier(&clip_dev_notifier);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 874) register_inetaddr_notifier(&clip_inet_notifier);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 875)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 876) timer_setup(&idle_timer, idle_timer_check, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 877)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 878) #ifdef CONFIG_PROC_FS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 879) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 880) struct proc_dir_entry *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 881)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 882) p = proc_create_net("arp", 0444, atm_proc_root, &arp_seq_ops,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 883) sizeof(struct clip_seq_state));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 884) if (!p) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 885) pr_err("Unable to initialize /proc/net/atm/arp\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 886) atm_clip_exit_noproc();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 887) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 888) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 889) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 890) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 891)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 892) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 893) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 894)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 895) static void atm_clip_exit_noproc(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 896) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 897) struct net_device *dev, *next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 898)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 899) unregister_inetaddr_notifier(&clip_inet_notifier);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 900) unregister_netdevice_notifier(&clip_dev_notifier);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 901)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 902) deregister_atm_ioctl(&clip_ioctl_ops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 903)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 904) /* First, stop the idle timer, so it stops banging
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 905) * on the table.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 906) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 907) del_timer_sync(&idle_timer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 908)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 909) dev = clip_devs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 910) while (dev) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 911) next = PRIV(dev)->next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 912) unregister_netdev(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 913) free_netdev(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 914) dev = next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 915) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 916) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 917)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 918) static void __exit atm_clip_exit(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 919) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 920) remove_proc_entry("arp", atm_proc_root);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 921)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 922) atm_clip_exit_noproc();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 923) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 924)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 925) module_init(atm_clip_init);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 926) module_exit(atm_clip_exit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 927) MODULE_AUTHOR("Werner Almesberger");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 928) MODULE_DESCRIPTION("Classical/IP over ATM interface");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 929) MODULE_LICENSE("GPL");