rtnetlink.c (7bf2357524408b97fec58344caf7397f8140c3fd) | rtnetlink.c (d40156aa5ecbd51fed932ed4813df82b56e5ff4d) |
---|---|
1/* 2 * INET An implementation of the TCP/IP protocol suite for the LINUX 3 * operating system. INET is implemented using the BSD Socket 4 * interface as the means of communication with the user level. 5 * 6 * Routing netlink socket interface: protocol independent part. 7 * 8 * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru> --- 527 unchanged lines hidden (view full) --- 536 [RTM_FAM(RTM_NEWROUTE)] = RTA_MAX, 537 [RTM_FAM(RTM_NEWRULE)] = FRA_MAX, 538 [RTM_FAM(RTM_NEWQDISC)] = TCA_MAX, 539 [RTM_FAM(RTM_NEWTCLASS)] = TCA_MAX, 540 [RTM_FAM(RTM_NEWTFILTER)] = TCA_MAX, 541 [RTM_FAM(RTM_NEWACTION)] = TCAA_MAX, 542}; 543 | 1/* 2 * INET An implementation of the TCP/IP protocol suite for the LINUX 3 * operating system. INET is implemented using the BSD Socket 4 * interface as the means of communication with the user level. 5 * 6 * Routing netlink socket interface: protocol independent part. 7 * 8 * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru> --- 527 unchanged lines hidden (view full) --- 536 [RTM_FAM(RTM_NEWROUTE)] = RTA_MAX, 537 [RTM_FAM(RTM_NEWRULE)] = FRA_MAX, 538 [RTM_FAM(RTM_NEWQDISC)] = TCA_MAX, 539 [RTM_FAM(RTM_NEWTCLASS)] = TCA_MAX, 540 [RTM_FAM(RTM_NEWTFILTER)] = TCA_MAX, 541 [RTM_FAM(RTM_NEWACTION)] = TCAA_MAX, 542}; 543 |
544void __rta_fill(struct sk_buff *skb, int attrtype, int attrlen, const void *data) 545{ 546 struct rtattr *rta; 547 int size = RTA_LENGTH(attrlen); 548 549 rta = (struct rtattr *)skb_put(skb, RTA_ALIGN(size)); 550 rta->rta_type = attrtype; 551 rta->rta_len = size; 552 memcpy(RTA_DATA(rta), data, attrlen); 553 memset(RTA_DATA(rta) + attrlen, 0, RTA_ALIGN(size) - size); 554} 555EXPORT_SYMBOL(__rta_fill); 556 | |
557int rtnetlink_send(struct sk_buff *skb, struct net *net, u32 pid, unsigned int group, int echo) 558{ 559 struct sock *rtnl = net->rtnl; 560 int err = 0; 561 562 NETLINK_CB(skb).dst_group = group; 563 if (echo) 564 atomic_inc(&skb->users); --- 58 unchanged lines hidden (view full) --- 623 624nla_put_failure: 625 nla_nest_cancel(skb, mx); 626 return -EMSGSIZE; 627} 628EXPORT_SYMBOL(rtnetlink_put_metrics); 629 630int rtnl_put_cacheinfo(struct sk_buff *skb, struct dst_entry *dst, u32 id, | 544int rtnetlink_send(struct sk_buff *skb, struct net *net, u32 pid, unsigned int group, int echo) 545{ 546 struct sock *rtnl = net->rtnl; 547 int err = 0; 548 549 NETLINK_CB(skb).dst_group = group; 550 if (echo) 551 atomic_inc(&skb->users); --- 58 unchanged lines hidden (view full) --- 610 611nla_put_failure: 612 nla_nest_cancel(skb, mx); 613 return -EMSGSIZE; 614} 615EXPORT_SYMBOL(rtnetlink_put_metrics); 616 617int rtnl_put_cacheinfo(struct sk_buff *skb, struct dst_entry *dst, u32 id, |
631 u32 ts, u32 tsage, long expires, u32 error) | 618 long expires, u32 error) |
632{ 633 struct rta_cacheinfo ci = { 634 .rta_lastuse = jiffies_to_clock_t(jiffies - dst->lastuse), 635 .rta_used = dst->__use, 636 .rta_clntref = atomic_read(&(dst->__refcnt)), 637 .rta_error = error, 638 .rta_id = id, | 619{ 620 struct rta_cacheinfo ci = { 621 .rta_lastuse = jiffies_to_clock_t(jiffies - dst->lastuse), 622 .rta_used = dst->__use, 623 .rta_clntref = atomic_read(&(dst->__refcnt)), 624 .rta_error = error, 625 .rta_id = id, |
639 .rta_ts = ts, 640 .rta_tsage = tsage, | |
641 }; 642 643 if (expires) 644 ci.rta_expires = jiffies_to_clock_t(expires); 645 646 return nla_put(skb, RTA_CACHEINFO, sizeof(ci), &ci); 647} 648EXPORT_SYMBOL_GPL(rtnl_put_cacheinfo); --- 724 unchanged lines hidden (view full) --- 1373 memcpy(sa->sa_data, nla_data(tb[IFLA_ADDRESS]), 1374 dev->addr_len); 1375 err = ops->ndo_set_mac_address(dev, sa); 1376 kfree(sa); 1377 if (err) 1378 goto errout; 1379 send_addr_notify = 1; 1380 modified = 1; | 626 }; 627 628 if (expires) 629 ci.rta_expires = jiffies_to_clock_t(expires); 630 631 return nla_put(skb, RTA_CACHEINFO, sizeof(ci), &ci); 632} 633EXPORT_SYMBOL_GPL(rtnl_put_cacheinfo); --- 724 unchanged lines hidden (view full) --- 1358 memcpy(sa->sa_data, nla_data(tb[IFLA_ADDRESS]), 1359 dev->addr_len); 1360 err = ops->ndo_set_mac_address(dev, sa); 1361 kfree(sa); 1362 if (err) 1363 goto errout; 1364 send_addr_notify = 1; 1365 modified = 1; |
1381 add_device_randomness(dev->dev_addr, dev->addr_len); | |
1382 } 1383 1384 if (tb[IFLA_MTU]) { 1385 err = dev_set_mtu(dev, nla_get_u32(tb[IFLA_MTU])); 1386 if (err < 0) 1387 goto errout; 1388 modified = 1; 1389 } --- 245 unchanged lines hidden (view full) --- 1635} 1636EXPORT_SYMBOL(rtnl_configure_link); 1637 1638struct net_device *rtnl_create_link(struct net *src_net, struct net *net, 1639 char *ifname, const struct rtnl_link_ops *ops, struct nlattr *tb[]) 1640{ 1641 int err; 1642 struct net_device *dev; | 1366 } 1367 1368 if (tb[IFLA_MTU]) { 1369 err = dev_set_mtu(dev, nla_get_u32(tb[IFLA_MTU])); 1370 if (err < 0) 1371 goto errout; 1372 modified = 1; 1373 } --- 245 unchanged lines hidden (view full) --- 1619} 1620EXPORT_SYMBOL(rtnl_configure_link); 1621 1622struct net_device *rtnl_create_link(struct net *src_net, struct net *net, 1623 char *ifname, const struct rtnl_link_ops *ops, struct nlattr *tb[]) 1624{ 1625 int err; 1626 struct net_device *dev; |
1643 unsigned int num_queues = 1; | 1627 unsigned int num_tx_queues = 1; 1628 unsigned int num_rx_queues = 1; |
1644 | 1629 |
1645 if (ops->get_tx_queues) { 1646 err = ops->get_tx_queues(src_net, tb); 1647 if (err < 0) 1648 goto err; 1649 num_queues = err; 1650 } | 1630 if (ops->get_num_tx_queues) 1631 num_tx_queues = ops->get_num_tx_queues(); 1632 if (ops->get_num_rx_queues) 1633 num_rx_queues = ops->get_num_rx_queues(); |
1651 1652 err = -ENOMEM; | 1634 1635 err = -ENOMEM; |
1653 dev = alloc_netdev_mq(ops->priv_size, ifname, ops->setup, num_queues); | 1636 dev = alloc_netdev_mqs(ops->priv_size, ifname, ops->setup, 1637 num_tx_queues, num_rx_queues); |
1654 if (!dev) 1655 goto err; 1656 1657 dev_net_set(dev, net); 1658 dev->rtnl_link_ops = ops; 1659 dev->rtnl_link_state = RTNL_LINK_INITIALIZING; 1660 1661 if (tb[IFLA_MTU]) --- 523 unchanged lines hidden (view full) --- 2185 return err; 2186skip: 2187 *idx += 1; 2188 } 2189 return 0; 2190} 2191 2192/** | 1638 if (!dev) 1639 goto err; 1640 1641 dev_net_set(dev, net); 1642 dev->rtnl_link_ops = ops; 1643 dev->rtnl_link_state = RTNL_LINK_INITIALIZING; 1644 1645 if (tb[IFLA_MTU]) --- 523 unchanged lines hidden (view full) --- 2169 return err; 2170skip: 2171 *idx += 1; 2172 } 2173 return 0; 2174} 2175 2176/** |
2193 * ndo_dflt_fdb_dump: default netdevice operation to dump an FDB table. | 2177 * ndo_dflt_fdb_dump - default netdevice operation to dump an FDB table. |
2194 * @nlh: netlink message header 2195 * @dev: netdevice 2196 * 2197 * Default netdevice operation to dump the existing unicast address list. 2198 * Returns zero on success. 2199 */ 2200int ndo_dflt_fdb_dump(struct sk_buff *skb, 2201 struct netlink_callback *cb, --- 160 unchanged lines hidden (view full) --- 2362static struct notifier_block rtnetlink_dev_notifier = { 2363 .notifier_call = rtnetlink_event, 2364}; 2365 2366 2367static int __net_init rtnetlink_net_init(struct net *net) 2368{ 2369 struct sock *sk; | 2178 * @nlh: netlink message header 2179 * @dev: netdevice 2180 * 2181 * Default netdevice operation to dump the existing unicast address list. 2182 * Returns zero on success. 2183 */ 2184int ndo_dflt_fdb_dump(struct sk_buff *skb, 2185 struct netlink_callback *cb, --- 160 unchanged lines hidden (view full) --- 2346static struct notifier_block rtnetlink_dev_notifier = { 2347 .notifier_call = rtnetlink_event, 2348}; 2349 2350 2351static int __net_init rtnetlink_net_init(struct net *net) 2352{ 2353 struct sock *sk; |
2370 sk = netlink_kernel_create(net, NETLINK_ROUTE, RTNLGRP_MAX, 2371 rtnetlink_rcv, &rtnl_mutex, THIS_MODULE); | 2354 struct netlink_kernel_cfg cfg = { 2355 .groups = RTNLGRP_MAX, 2356 .input = rtnetlink_rcv, 2357 .cb_mutex = &rtnl_mutex, 2358 }; 2359 2360 sk = netlink_kernel_create(net, NETLINK_ROUTE, THIS_MODULE, &cfg); |
2372 if (!sk) 2373 return -ENOMEM; 2374 net->rtnl = sk; 2375 return 0; 2376} 2377 2378static void __net_exit rtnetlink_net_exit(struct net *net) 2379{ --- 41 unchanged lines hidden --- | 2361 if (!sk) 2362 return -ENOMEM; 2363 net->rtnl = sk; 2364 return 0; 2365} 2366 2367static void __net_exit rtnetlink_net_exit(struct net *net) 2368{ --- 41 unchanged lines hidden --- |