cregit-Linux how code gets into the kernel

Release 4.14 net/atm/addr.c

Directory: net/atm
// SPDX-License-Identifier: GPL-2.0
/* net/atm/addr.c - Local ATM address registry */

/* Written 1995-2000 by Werner Almesberger, EPFL LRC/ICA */

#include <linux/atm.h>
#include <linux/atmdev.h>
#include <linux/slab.h>
#include <linux/uaccess.h>

#include "signaling.h"
#include "addr.h"


static int check_addr(const struct sockaddr_atmsvc *addr) { int i; if (addr->sas_family != AF_ATMSVC) return -EAFNOSUPPORT; if (!*addr->sas_addr.pub) return *addr->sas_addr.prv ? 0 : -EINVAL; for (i = 1; i < ATM_E164_LEN + 1; i++) /* make sure it's \0-terminated */ if (!addr->sas_addr.pub[i]) return 0; return -EINVAL; }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)8498.82%266.67%
Mitchell Blank Jr.11.18%133.33%
Total85100.00%3100.00%


static int identical(const struct sockaddr_atmsvc *a, const struct sockaddr_atmsvc *b) { if (*a->sas_addr.prv) if (memcmp(a->sas_addr.prv, b->sas_addr.prv, ATM_ESA_LEN)) return 0; if (!*a->sas_addr.pub) return !*b->sas_addr.pub; if (!*b->sas_addr.pub) return 0; return !strcmp(a->sas_addr.pub, b->sas_addr.pub); }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)9697.96%150.00%
Mitchell Blank Jr.22.04%150.00%
Total98100.00%2100.00%


static void notify_sigd(const struct atm_dev *dev) { struct sockaddr_atmpvc pvc; pvc.sap_addr.itf = dev->number; sigd_enq(NULL, as_itf_notify, NULL, &pvc, NULL); }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)3997.50%150.00%
Mitchell Blank Jr.12.50%150.00%
Total40100.00%2100.00%


void atm_reset_addr(struct atm_dev *dev, enum atm_addr_type_t atype) { unsigned long flags; struct atm_dev_addr *this, *p; struct list_head *head; spin_lock_irqsave(&dev->lock, flags); if (atype == ATM_ADDR_LECS) head = &dev->lecs; else head = &dev->local; list_for_each_entry_safe(this, p, head, entry) { list_del(&this->entry); kfree(this); } spin_unlock_irqrestore(&dev->lock, flags); if (head == &dev->local) notify_sigd(dev); }

Contributors

PersonTokensPropCommitsCommitProp
Eric Kinzie4036.04%114.29%
Linus Torvalds (pre-git)3228.83%228.57%
Chas Williams2825.23%228.57%
Martin Whitaker109.01%114.29%
Linus Torvalds10.90%114.29%
Total111100.00%7100.00%


int atm_add_addr(struct atm_dev *dev, const struct sockaddr_atmsvc *addr, enum atm_addr_type_t atype) { unsigned long flags; struct atm_dev_addr *this; struct list_head *head; int error; error = check_addr(addr); if (error) return error; spin_lock_irqsave(&dev->lock, flags); if (atype == ATM_ADDR_LECS) head = &dev->lecs; else head = &dev->local; list_for_each_entry(this, head, entry) { if (identical(&this->addr, addr)) { spin_unlock_irqrestore(&dev->lock, flags); return -EEXIST; } } this = kmalloc(sizeof(struct atm_dev_addr), GFP_ATOMIC); if (!this) { spin_unlock_irqrestore(&dev->lock, flags); return -ENOMEM; } this->addr = *addr; list_add(&this->entry, head); spin_unlock_irqrestore(&dev->lock, flags); if (head == &dev->local) notify_sigd(dev); return 0; }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)10553.03%228.57%
Chas Williams5025.25%228.57%
Eric Kinzie4120.71%114.29%
Mitchell Blank Jr.10.51%114.29%
Linus Torvalds10.51%114.29%
Total198100.00%7100.00%


int atm_del_addr(struct atm_dev *dev, const struct sockaddr_atmsvc *addr, enum atm_addr_type_t atype) { unsigned long flags; struct atm_dev_addr *this; struct list_head *head; int error; error = check_addr(addr); if (error) return error; spin_lock_irqsave(&dev->lock, flags); if (atype == ATM_ADDR_LECS) head = &dev->lecs; else head = &dev->local; list_for_each_entry(this, head, entry) { if (identical(&this->addr, addr)) { list_del(&this->entry); spin_unlock_irqrestore(&dev->lock, flags); kfree(this); if (head == &dev->local) notify_sigd(dev); return 0; } } spin_unlock_irqrestore(&dev->lock, flags); return -ENOENT; }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)6741.88%228.57%
Chas Williams5131.88%228.57%
Eric Kinzie4025.00%114.29%
Mitchell Blank Jr.10.62%114.29%
Linus Torvalds10.62%114.29%
Total160100.00%7100.00%


int atm_get_addr(struct atm_dev *dev, struct sockaddr_atmsvc __user * buf, size_t size, enum atm_addr_type_t atype) { unsigned long flags; struct atm_dev_addr *this; struct list_head *head; int total = 0, error; struct sockaddr_atmsvc *tmp_buf, *tmp_bufp; spin_lock_irqsave(&dev->lock, flags); if (atype == ATM_ADDR_LECS) head = &dev->lecs; else head = &dev->local; list_for_each_entry(this, head, entry) total += sizeof(struct sockaddr_atmsvc); tmp_buf = tmp_bufp = kmalloc(total, GFP_ATOMIC); if (!tmp_buf) { spin_unlock_irqrestore(&dev->lock, flags); return -ENOMEM; } list_for_each_entry(this, head, entry) memcpy(tmp_bufp++, &this->addr, sizeof(struct sockaddr_atmsvc)); spin_unlock_irqrestore(&dev->lock, flags); error = total > size ? -E2BIG : total; if (copy_to_user(buf, tmp_buf, total < size ? total : size)) error = -EFAULT; kfree(tmp_buf); return error; }

Contributors

PersonTokensPropCommitsCommitProp
Chas Williams10148.79%333.33%
Linus Torvalds (pre-git)6933.33%222.22%
Eric Kinzie3215.46%111.11%
Al Viro31.45%111.11%
Linus Torvalds20.97%222.22%
Total207100.00%9100.00%


Overall Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)50855.22%320.00%
Chas Williams23025.00%320.00%
Eric Kinzie15316.63%16.67%
Martin Whitaker101.09%16.67%
Mitchell Blank Jr.60.65%16.67%
Linus Torvalds50.54%213.33%
Tejun Heo30.33%16.67%
Al Viro30.33%16.67%
Greg Kroah-Hartman10.11%16.67%
Joe Perches10.11%16.67%
Total920100.00%15100.00%
Directory: net/atm
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.
Created with cregit.