Release 4.11 net/x25/x25_dev.c
/*
* 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.
* 2000-09-04 Henner Eisen Prevent freeing a dangling skb.
*/
#define pr_fmt(fmt) "X25: " fmt
#include <linux/kernel.h>
#include <linux/netdevice.h>
#include <linux/skbuff.h>
#include <linux/slab.h>
#include <net/sock.h>
#include <linux/if_arp.h>
#include <net/x25.h>
#include <net/x25device.h>
static int x25_receive_data(struct sk_buff *skb, struct x25_neigh *nb)
{
struct sock *sk;
unsigned short frametype;
unsigned int lci;
if (!pskb_may_pull(skb, X25_STD_MIN_LEN))
return 0;
frametype = skb->data[2];
lci = ((skb->data[0] << 8) & 0xF00) + ((skb->data[1] << 0) & 0x0FF);
/*
* LCI of zero is always for us, and its always a link control
* frame.
*/
if (lci == 0) {
x25_link_control(skb, nb, frametype);
return 0;
}
/*
* Find an existing socket.
*/
if ((sk = x25_find_socket(lci, nb)) != NULL) {
int queued = 1;
skb_reset_transport_header(skb);
bh_lock_sock(sk);
if (!sock_owned_by_user(sk)) {
queued = x25_process_rx_frame(sk, skb);
} else {
queued = !sk_add_backlog(sk, skb, sk->sk_rcvbuf);
}
bh_unlock_sock(sk);
sock_put(sk);
return queued;
}
/*
* Is is a Call Request ? if so process it.
*/
if (frametype == X25_CALL_REQUEST)
return x25_rx_call_request(skb, nb, lci);
/*
* Its not a Call Request, nor is it a control frame.
* Can we forward it?
*/
if (x25_forward_data(lci, nb, skb)) {
if (frametype == X25_CLEAR_CONFIRMATION) {
x25_clear_forward_by_lci(lci);
}
kfree_skb(skb);
return 1;
}
/*
x25_transmit_clear_request(nb, lci, 0x0D);
*/
if (frametype != X25_CLEAR_CONFIRMATION)
pr_debug("x25_receive_data(): unknown frame type %2x\n",frametype);
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Linus Torvalds (pre-git) | 176 | 69.02% | 5 | 31.25% |
Andrew Hendry | 40 | 15.69% | 2 | 12.50% |
Matthew Daley | 13 | 5.10% | 1 | 6.25% |
Arnaldo Carvalho de Melo | 8 | 3.14% | 2 | 12.50% |
Andrew Morton | 6 | 2.35% | 1 | 6.25% |
Yi Zhu | 4 | 1.57% | 2 | 12.50% |
Eric Dumazet | 4 | 1.57% | 1 | 6.25% |
Benjamin LaHaise | 3 | 1.18% | 1 | 6.25% |
Wang Weidong | 1 | 0.39% | 1 | 6.25% |
Total | 255 | 100.00% | 16 | 100.00% |
int x25_lapb_receive_frame(struct sk_buff *skb, struct net_device *dev,
struct packet_type *ptype, struct net_device *orig_dev)
{
struct sk_buff *nskb;
struct x25_neigh *nb;
if (!net_eq(dev_net(dev), &init_net))
goto drop;
nskb = skb_copy(skb, GFP_ATOMIC);
if (!nskb)
goto drop;
kfree_skb(skb);
skb = nskb;
/*
* Packet received from unrecognised device, throw it away.
*/
nb = x25_get_neigh(dev);
if (!nb) {
pr_debug("unknown neighbour - %s\n", dev->name);
goto drop;
}
if (!pskb_may_pull(skb, 1))
return 0;
switch (skb->data[0]) {
case X25_IFACE_DATA:
skb_pull(skb, 1);
if (x25_receive_data(skb, nb)) {
x25_neigh_put(nb);
goto out;
}
break;
case X25_IFACE_CONNECT:
x25_link_established(nb);
break;
case X25_IFACE_DISCONNECT:
x25_link_terminated(nb);
break;
}
x25_neigh_put(nb);
drop:
kfree_skb(skb);
out:
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Linus Torvalds (pre-git) | 93 | 47.94% | 5 | 35.71% |
David S. Miller | 33 | 17.01% | 2 | 14.29% |
Arnaldo Carvalho de Melo | 33 | 17.01% | 1 | 7.14% |
Matthew Daley | 13 | 6.70% | 1 | 7.14% |
Eric W. Biedermann | 9 | 4.64% | 1 | 7.14% |
Hideaki Yoshifuji / 吉藤英明 | 8 | 4.12% | 2 | 14.29% |
Andrew Hendry | 3 | 1.55% | 1 | 7.14% |
Wang Weidong | 2 | 1.03% | 1 | 7.14% |
Total | 194 | 100.00% | 14 | 100.00% |
void x25_establish_link(struct x25_neigh *nb)
{
struct sk_buff *skb;
unsigned char *ptr;
switch (nb->dev->type) {
case ARPHRD_X25:
if ((skb = alloc_skb(1, GFP_ATOMIC)) == NULL) {
pr_err("x25_dev: out of memory\n");
return;
}
ptr = skb_put(skb, 1);
*ptr = X25_IFACE_CONNECT;
break;
#if IS_ENABLED(CONFIG_LLC)
case ARPHRD_ETHER:
return;
#endif
default:
return;
}
skb->protocol = htons(ETH_P_X25);
skb->dev = nb->dev;
dev_queue_xmit(skb);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Linus Torvalds (pre-git) | 101 | 94.39% | 2 | 33.33% |
Arnaldo Carvalho de Melo | 3 | 2.80% | 1 | 16.67% |
Wang Weidong | 1 | 0.93% | 1 | 16.67% |
Andrew Hendry | 1 | 0.93% | 1 | 16.67% |
Igor Maravić | 1 | 0.93% | 1 | 16.67% |
Total | 107 | 100.00% | 6 | 100.00% |
void x25_terminate_link(struct x25_neigh *nb)
{
struct sk_buff *skb;
unsigned char *ptr;
#if IS_ENABLED(CONFIG_LLC)
if (nb->dev->type == ARPHRD_ETHER)
return;
#endif
if (nb->dev->type != ARPHRD_X25)
return;
skb = alloc_skb(1, GFP_ATOMIC);
if (!skb) {
pr_err("x25_dev: out of memory\n");
return;
}
ptr = skb_put(skb, 1);
*ptr = X25_IFACE_DISCONNECT;
skb->protocol = htons(ETH_P_X25);
skb->dev = nb->dev;
dev_queue_xmit(skb);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Linus Torvalds (pre-git) | 77 | 71.30% | 2 | 33.33% |
Arnaldo Carvalho de Melo | 28 | 25.93% | 1 | 16.67% |
Wang Weidong | 1 | 0.93% | 1 | 16.67% |
Igor Maravić | 1 | 0.93% | 1 | 16.67% |
Andrew Hendry | 1 | 0.93% | 1 | 16.67% |
Total | 108 | 100.00% | 6 | 100.00% |
void x25_send_frame(struct sk_buff *skb, struct x25_neigh *nb)
{
unsigned char *dptr;
skb_reset_network_header(skb);
switch (nb->dev->type) {
case ARPHRD_X25:
dptr = skb_push(skb, 1);
*dptr = X25_IFACE_DATA;
break;
#if IS_ENABLED(CONFIG_LLC)
case ARPHRD_ETHER:
kfree_skb(skb);
return;
#endif
default:
kfree_skb(skb);
return;
}
skb->protocol = htons(ETH_P_X25);
skb->dev = nb->dev;
dev_queue_xmit(skb);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Linus Torvalds (pre-git) | 91 | 91.92% | 3 | 42.86% |
Arnaldo Carvalho de Melo | 6 | 6.06% | 2 | 28.57% |
Igor Maravić | 1 | 1.01% | 1 | 14.29% |
Andrew Hendry | 1 | 1.01% | 1 | 14.29% |
Total | 99 | 100.00% | 7 | 100.00% |
Overall Contributors
Person | Tokens | Prop | Commits | CommitProp |
Linus Torvalds (pre-git) | 556 | 69.94% | 9 | 30.00% |
Arnaldo Carvalho de Melo | 78 | 9.81% | 3 | 10.00% |
Andrew Hendry | 49 | 6.16% | 3 | 10.00% |
David S. Miller | 33 | 4.15% | 2 | 6.67% |
Matthew Daley | 26 | 3.27% | 1 | 3.33% |
Wang Weidong | 12 | 1.51% | 1 | 3.33% |
Hideaki Yoshifuji / 吉藤英明 | 9 | 1.13% | 3 | 10.00% |
Eric W. Biedermann | 9 | 1.13% | 1 | 3.33% |
Andrew Morton | 6 | 0.75% | 1 | 3.33% |
Yi Zhu | 4 | 0.50% | 2 | 6.67% |
Eric Dumazet | 4 | 0.50% | 1 | 3.33% |
Benjamin LaHaise | 3 | 0.38% | 1 | 3.33% |
Igor Maravić | 3 | 0.38% | 1 | 3.33% |
Tejun Heo | 3 | 0.38% | 1 | 3.33% |
Total | 795 | 100.00% | 30 | 100.00% |
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.