cregit-Linux how code gets into the kernel

Release 4.11 net/x25/x25_link.c

Directory: net/x25
/*
 *      X.25 Packet Layer release 002
 *
 *      This is ALPHA test software. This code may break your machine,
 *      randomly fail to work with new releases, misbehave and/or generally
 *      screw up. It might even work.
 *
 *      This code REQUIRES 2.1.15 or higher
 *
 *      This module:
 *              This module is free software; you can redistribute it and/or
 *              modify it under the terms of the GNU General Public License
 *              as published by the Free Software Foundation; either version
 *              2 of the License, or (at your option) any later version.
 *
 *      History
 *      X.25 001        Jonathan Naylor   Started coding.
 *      X.25 002        Jonathan Naylor   New timer architecture.
 *      mar/20/00       Daniela Squassoni Disabling/enabling of facilities
 *                                        negotiation.
 *      2000-09-04      Henner Eisen      dev_hold() / dev_put() for x25_neigh.
 */


#define pr_fmt(fmt) "X25: " fmt

#include <linux/kernel.h>
#include <linux/jiffies.h>
#include <linux/timer.h>
#include <linux/slab.h>
#include <linux/netdevice.h>
#include <linux/skbuff.h>
#include <linux/uaccess.h>
#include <linux/init.h>
#include <net/x25.h>


LIST_HEAD(x25_neigh_list);

DEFINE_RWLOCK(x25_neigh_list_lock);

static void x25_t20timer_expiry(unsigned long);

static void x25_transmit_restart_confirmation(struct x25_neigh *nb);
static void x25_transmit_restart_request(struct x25_neigh *nb);

/*
 *      Linux set/reset timer routines
 */

static inline void x25_start_t20timer(struct x25_neigh *nb) { mod_timer(&nb->t20timer, jiffies + nb->t20); }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)2076.92%250.00%
Arnaldo Carvalho de Melo311.54%125.00%
Vinay K. Nallamothu311.54%125.00%
Total26100.00%4100.00%


static void x25_t20timer_expiry(unsigned long param) { struct x25_neigh *nb = (struct x25_neigh *)param; x25_transmit_restart_request(nb); x25_start_t20timer(nb); }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)2990.62%266.67%
Arnaldo Carvalho de Melo39.38%133.33%
Total32100.00%3100.00%


static inline void x25_stop_t20timer(struct x25_neigh *nb) { del_timer(&nb->t20timer); }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)1785.00%250.00%
Arnaldo Carvalho de Melo210.00%125.00%
Vinay K. Nallamothu15.00%125.00%
Total20100.00%4100.00%


static inline int x25_t20timer_pending(struct x25_neigh *nb) { return timer_pending(&nb->t20timer); }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)1885.71%133.33%
Arnaldo Carvalho de Melo29.52%133.33%
Vinay K. Nallamothu14.76%133.33%
Total21100.00%3100.00%

/* * This handles all restart and diagnostic frames. */
void x25_link_control(struct sk_buff *skb, struct x25_neigh *nb, unsigned short frametype) { struct sk_buff *skbn; int confirm; switch (frametype) { case X25_RESTART_REQUEST: confirm = !x25_t20timer_pending(nb); x25_stop_t20timer(nb); nb->state = X25_LINK_STATE_3; if (confirm) x25_transmit_restart_confirmation(nb); break; case X25_RESTART_CONFIRMATION: x25_stop_t20timer(nb); nb->state = X25_LINK_STATE_3; break; case X25_DIAGNOSTIC: if (!pskb_may_pull(skb, X25_STD_MIN_LEN + 4)) break; pr_warn("diagnostic #%d - %02X %02X %02X\n", skb->data[3], skb->data[4], skb->data[5], skb->data[6]); break; default: pr_warn("received unknown %02X with LCI 000\n", frametype); break; } if (nb->state == X25_LINK_STATE_3) while ((skbn = skb_dequeue(&nb->queue)) != NULL) x25_send_frame(skbn, nb); }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)14384.12%562.50%
Matthew Daley137.65%112.50%
Arnaldo Carvalho de Melo105.88%112.50%
Wang Weidong42.35%112.50%
Total170100.00%8100.00%

/* * This routine is called when a Restart Request is needed */
static void x25_transmit_restart_request(struct x25_neigh *nb) { unsigned char *dptr; int len = X25_MAX_L2_LEN + X25_STD_MIN_LEN + 2; struct sk_buff *skb = alloc_skb(len, GFP_ATOMIC); if (!skb) return; skb_reserve(skb, X25_MAX_L2_LEN); dptr = skb_put(skb, X25_STD_MIN_LEN + 2); *dptr++ = nb->extended ? X25_GFI_EXTSEQ : X25_GFI_STDSEQ; *dptr++ = 0x00; *dptr++ = X25_RESTART_REQUEST; *dptr++ = 0x00; *dptr++ = 0; skb->sk = NULL; x25_send_frame(skb, nb); }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)9586.36%125.00%
Arnaldo Carvalho de Melo1412.73%250.00%
Adrian Bunk10.91%125.00%
Total110100.00%4100.00%

/* * This routine is called when a Restart Confirmation is needed */
static void x25_transmit_restart_confirmation(struct x25_neigh *nb) { unsigned char *dptr; int len = X25_MAX_L2_LEN + X25_STD_MIN_LEN; struct sk_buff *skb = alloc_skb(len, GFP_ATOMIC); if (!skb) return; skb_reserve(skb, X25_MAX_L2_LEN); dptr = skb_put(skb, X25_STD_MIN_LEN); *dptr++ = nb->extended ? X25_GFI_EXTSEQ : X25_GFI_STDSEQ; *dptr++ = 0x00; *dptr++ = X25_RESTART_CONFIRMATION; skb->sk = NULL; x25_send_frame(skb, nb); }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)7984.04%125.00%
Arnaldo Carvalho de Melo1414.89%250.00%
Adrian Bunk11.06%125.00%
Total94100.00%4100.00%

/* * This routine is called when a Clear Request is needed outside of the context * of a connected socket. */
void x25_transmit_clear_request(struct x25_neigh *nb, unsigned int lci, unsigned char cause) { unsigned char *dptr; int len = X25_MAX_L2_LEN + X25_STD_MIN_LEN + 2; struct sk_buff *skb = alloc_skb(len, GFP_ATOMIC); if (!skb) return; skb_reserve(skb, X25_MAX_L2_LEN); dptr = skb_put(skb, X25_STD_MIN_LEN + 2); *dptr++ = ((lci >> 8) & 0x0F) | (nb->extended ? X25_GFI_EXTSEQ : X25_GFI_STDSEQ); *dptr++ = (lci >> 0) & 0xFF; *dptr++ = X25_CLEAR_REQUEST; *dptr++ = cause; *dptr++ = 0x00; skb->sk = NULL; x25_send_frame(skb, nb); }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)11988.15%125.00%
Arnaldo Carvalho de Melo1410.37%250.00%
Rusty Russell21.48%125.00%
Total135100.00%4100.00%


void x25_transmit_link(struct sk_buff *skb, struct x25_neigh *nb) { switch (nb->state) { case X25_LINK_STATE_0: skb_queue_tail(&nb->queue, skb); nb->state = X25_LINK_STATE_1; x25_establish_link(nb); break; case X25_LINK_STATE_1: case X25_LINK_STATE_2: skb_queue_tail(&nb->queue, skb); break; case X25_LINK_STATE_3: x25_send_frame(skb, nb); break; } }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)6990.79%266.67%
Arnaldo Carvalho de Melo79.21%133.33%
Total76100.00%3100.00%

/* * Called when the link layer has become established. */
void x25_link_established(struct x25_neigh *nb) { switch (nb->state) { case X25_LINK_STATE_0: nb->state = X25_LINK_STATE_2; break; case X25_LINK_STATE_1: x25_transmit_restart_request(nb); nb->state = X25_LINK_STATE_2; x25_start_t20timer(nb); break; } }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)4287.50%375.00%
Arnaldo Carvalho de Melo612.50%125.00%
Total48100.00%4100.00%

/* * Called when the link layer has terminated, or an establishment * request has failed. */
void x25_link_terminated(struct x25_neigh *nb) { nb->state = X25_LINK_STATE_0; /* Out of order: clear existing virtual calls (X.25 03/93 4.6.3) */ x25_kill_by_neigh(nb); }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)1986.36%375.00%
Arnaldo Carvalho de Melo313.64%125.00%
Total22100.00%4100.00%

/* * Add a new device. */
void x25_link_device_up(struct net_device *dev) { struct x25_neigh *nb = kmalloc(sizeof(*nb), GFP_ATOMIC); if (!nb) return; skb_queue_head_init(&nb->queue); setup_timer(&nb->t20timer, x25_t20timer_expiry, (unsigned long)nb); dev_hold(dev); nb->dev = dev; nb->state = X25_LINK_STATE_0; nb->extended = 0; /* * Enables negotiation */ nb->global_facil_mask = X25_MASK_REVERSE | X25_MASK_THROUGHPUT | X25_MASK_PACKET_SIZE | X25_MASK_WINDOW_SIZE; nb->t20 = sysctl_x25_restart_request_timeout; atomic_set(&nb->refcnt, 1); write_lock_bh(&x25_neigh_list_lock); list_add(&nb->node, &x25_neigh_list); write_unlock_bh(&x25_neigh_list_lock); }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)7960.31%660.00%
Arnaldo Carvalho de Melo4131.30%220.00%
Vinay K. Nallamothu64.58%110.00%
Pavel Emelyanov53.82%110.00%
Total131100.00%10100.00%

/** * __x25_remove_neigh - remove neighbour from x25_neigh_list * @nb - neigh to remove * * Remove neighbour from x25_neigh_list. If it was there. * Caller must hold x25_neigh_list_lock. */
static void __x25_remove_neigh(struct x25_neigh *nb) { skb_queue_purge(&nb->queue); x25_stop_t20timer(nb); if (nb->node.next) { list_del(&nb->node); x25_neigh_put(nb); } }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)2859.57%240.00%
Arnaldo Carvalho de Melo1838.30%240.00%
Linus Torvalds12.13%120.00%
Total47100.00%5100.00%

/* * A device has been removed, remove its links. */
void x25_link_device_down(struct net_device *dev) { struct x25_neigh *nb; struct list_head *entry, *tmp; write_lock_bh(&x25_neigh_list_lock); list_for_each_safe(entry, tmp, &x25_neigh_list) { nb = list_entry(entry, struct x25_neigh, node); if (nb->dev == dev) { __x25_remove_neigh(nb); dev_put(dev); } } write_unlock_bh(&x25_neigh_list_lock); }

Contributors

PersonTokensPropCommitsCommitProp
Arnaldo Carvalho de Melo3950.65%125.00%
Linus Torvalds (pre-git)3849.35%375.00%
Total77100.00%4100.00%

/* * Given a device, return the neighbour address. */
struct x25_neigh *x25_get_neigh(struct net_device *dev) { struct x25_neigh *nb, *use = NULL; struct list_head *entry; read_lock_bh(&x25_neigh_list_lock); list_for_each(entry, &x25_neigh_list) { nb = list_entry(entry, struct x25_neigh, node); if (nb->dev == dev) { use = nb; break; } } if (use) x25_neigh_hold(use); read_unlock_bh(&x25_neigh_list_lock); return use; }

Contributors

PersonTokensPropCommitsCommitProp
Arnaldo Carvalho de Melo5968.60%250.00%
Linus Torvalds (pre-git)2731.40%250.00%
Total86100.00%4100.00%

/* * Handle the ioctls that control the subscription functions. */
int x25_subscr_ioctl(unsigned int cmd, void __user *arg) { struct x25_subscrip_struct x25_subscr; struct x25_neigh *nb; struct net_device *dev; int rc = -EINVAL; if (cmd != SIOCX25GSUBSCRIP && cmd != SIOCX25SSUBSCRIP) goto out; rc = -EFAULT; if (copy_from_user(&x25_subscr, arg, sizeof(x25_subscr))) goto out; rc = -EINVAL; if ((dev = x25_dev_get(x25_subscr.device)) == NULL) goto out; if ((nb = x25_get_neigh(dev)) == NULL) goto out_dev_put; dev_put(dev); if (cmd == SIOCX25GSUBSCRIP) { read_lock_bh(&x25_neigh_list_lock); x25_subscr.extended = nb->extended; x25_subscr.global_facil_mask = nb->global_facil_mask; read_unlock_bh(&x25_neigh_list_lock); rc = copy_to_user(arg, &x25_subscr, sizeof(x25_subscr)) ? -EFAULT : 0; } else { rc = -EINVAL; if (!(x25_subscr.extended && x25_subscr.extended != 1)) { rc = 0; write_lock_bh(&x25_neigh_list_lock); nb->extended = x25_subscr.extended; nb->global_facil_mask = x25_subscr.global_facil_mask; write_unlock_bh(&x25_neigh_list_lock); } } x25_neigh_put(nb); out: return rc; out_dev_put: dev_put(dev); goto out; }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)13755.47%660.00%
Arnaldo Carvalho de Melo8534.41%220.00%
Andrew Hendry249.72%110.00%
Al Viro10.40%110.00%
Total247100.00%10100.00%

/* * Release all memory associated with X.25 neighbour structures. */
void __exit x25_link_free(void) { struct x25_neigh *nb; struct list_head *entry, *tmp; write_lock_bh(&x25_neigh_list_lock); list_for_each_safe(entry, tmp, &x25_neigh_list) { struct net_device *dev; nb = list_entry(entry, struct x25_neigh, node); dev = nb->dev; __x25_remove_neigh(nb); dev_put(dev); } write_unlock_bh(&x25_neigh_list_lock); }

Contributors

PersonTokensPropCommitsCommitProp
Arnaldo Carvalho de Melo3850.00%120.00%
Linus Torvalds (pre-git)2127.63%120.00%
David S. Miller1114.47%120.00%
Apollon Oikonomopoulos56.58%120.00%
Linus Torvalds11.32%120.00%
Total76100.00%5100.00%


Overall Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)102067.82%1135.48%
Arnaldo Carvalho de Melo36224.07%26.45%
Andrew Hendry241.60%13.23%
Adrian Bunk221.46%13.23%
Matthew Daley130.86%13.23%
David S. Miller110.73%13.23%
Vinay K. Nallamothu110.73%13.23%
Wang Weidong110.73%13.23%
Linus Torvalds60.40%39.68%
Apollon Oikonomopoulos50.33%13.23%
Pavel Emelyanov50.33%13.23%
Thomas Gleixner40.27%13.23%
Tejun Heo30.20%13.23%
Rusty Russell30.20%26.45%
Cheng Renquan20.13%13.23%
Hideaki Yoshifuji / 吉藤英明10.07%13.23%
Al Viro10.07%13.23%
Total1504100.00%31100.00%
Directory: net/x25
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.
Created with cregit.