diff options
author | Thomas Graf <tgraf@suug.ch> | 2012-06-26 19:36:16 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2012-06-27 18:36:44 -0400 |
commit | 4c3af034fafeb7269176bf1310c9bcff0b9fd9bb (patch) | |
tree | e10a4be17401c237afc0b84edd386404174c4d05 | |
parent | 6b60978fde2b09a15d7aec0e15f2d3863bad2d24 (diff) |
netlink: Get rid of obsolete rtnetlink macros
Removes all RTA_GET*() and RTA_PUT*() variations, as well as the
the unused rtattr_strcmp(). Get rid of rtm_get_table() by moving
it to its only user decnet.
Signed-off-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | include/linux/rtnetlink.h | 129 | ||||
-rw-r--r-- | net/core/rtnetlink.c | 13 | ||||
-rw-r--r-- | net/decnet/dn_fib.c | 8 |
3 files changed, 8 insertions, 142 deletions
diff --git a/include/linux/rtnetlink.h b/include/linux/rtnetlink.h index 2c1de8982c85..ea60b0854109 100644 --- a/include/linux/rtnetlink.h +++ b/include/linux/rtnetlink.h | |||
@@ -612,12 +612,6 @@ struct tcamsg { | |||
612 | #include <linux/mutex.h> | 612 | #include <linux/mutex.h> |
613 | #include <linux/netdevice.h> | 613 | #include <linux/netdevice.h> |
614 | 614 | ||
615 | static __inline__ int rtattr_strcmp(const struct rtattr *rta, const char *str) | ||
616 | { | ||
617 | int len = strlen(str) + 1; | ||
618 | return len > rta->rta_len || memcmp(RTA_DATA(rta), str, len); | ||
619 | } | ||
620 | |||
621 | extern int rtnetlink_send(struct sk_buff *skb, struct net *net, u32 pid, u32 group, int echo); | 615 | extern int rtnetlink_send(struct sk_buff *skb, struct net *net, u32 pid, u32 group, int echo); |
622 | extern int rtnl_unicast(struct sk_buff *skb, struct net *net, u32 pid); | 616 | extern int rtnl_unicast(struct sk_buff *skb, struct net *net, u32 pid); |
623 | extern void rtnl_notify(struct sk_buff *skb, struct net *net, u32 pid, | 617 | extern void rtnl_notify(struct sk_buff *skb, struct net *net, u32 pid, |
@@ -628,122 +622,6 @@ extern int rtnl_put_cacheinfo(struct sk_buff *skb, struct dst_entry *dst, | |||
628 | u32 id, u32 ts, u32 tsage, long expires, | 622 | u32 id, u32 ts, u32 tsage, long expires, |
629 | u32 error); | 623 | u32 error); |
630 | 624 | ||
631 | extern void __rta_fill(struct sk_buff *skb, int attrtype, int attrlen, const void *data); | ||
632 | |||
633 | #define RTA_PUT(skb, attrtype, attrlen, data) \ | ||
634 | ({ if (unlikely(skb_tailroom(skb) < (int)RTA_SPACE(attrlen))) \ | ||
635 | goto rtattr_failure; \ | ||
636 | __rta_fill(skb, attrtype, attrlen, data); }) | ||
637 | |||
638 | #define RTA_APPEND(skb, attrlen, data) \ | ||
639 | ({ if (unlikely(skb_tailroom(skb) < (int)(attrlen))) \ | ||
640 | goto rtattr_failure; \ | ||
641 | memcpy(skb_put(skb, attrlen), data, attrlen); }) | ||
642 | |||
643 | #define RTA_PUT_NOHDR(skb, attrlen, data) \ | ||
644 | ({ RTA_APPEND(skb, RTA_ALIGN(attrlen), data); \ | ||
645 | memset(skb_tail_pointer(skb) - (RTA_ALIGN(attrlen) - attrlen), 0, \ | ||
646 | RTA_ALIGN(attrlen) - attrlen); }) | ||
647 | |||
648 | #define RTA_PUT_U8(skb, attrtype, value) \ | ||
649 | ({ u8 _tmp = (value); \ | ||
650 | RTA_PUT(skb, attrtype, sizeof(u8), &_tmp); }) | ||
651 | |||
652 | #define RTA_PUT_U16(skb, attrtype, value) \ | ||
653 | ({ u16 _tmp = (value); \ | ||
654 | RTA_PUT(skb, attrtype, sizeof(u16), &_tmp); }) | ||
655 | |||
656 | #define RTA_PUT_U32(skb, attrtype, value) \ | ||
657 | ({ u32 _tmp = (value); \ | ||
658 | RTA_PUT(skb, attrtype, sizeof(u32), &_tmp); }) | ||
659 | |||
660 | #define RTA_PUT_U64(skb, attrtype, value) \ | ||
661 | ({ u64 _tmp = (value); \ | ||
662 | RTA_PUT(skb, attrtype, sizeof(u64), &_tmp); }) | ||
663 | |||
664 | #define RTA_PUT_SECS(skb, attrtype, value) \ | ||
665 | RTA_PUT_U64(skb, attrtype, (value) / HZ) | ||
666 | |||
667 | #define RTA_PUT_MSECS(skb, attrtype, value) \ | ||
668 | RTA_PUT_U64(skb, attrtype, jiffies_to_msecs(value)) | ||
669 | |||
670 | #define RTA_PUT_STRING(skb, attrtype, value) \ | ||
671 | RTA_PUT(skb, attrtype, strlen(value) + 1, value) | ||
672 | |||
673 | #define RTA_PUT_FLAG(skb, attrtype) \ | ||
674 | RTA_PUT(skb, attrtype, 0, NULL); | ||
675 | |||
676 | #define RTA_NEST(skb, type) \ | ||
677 | ({ struct rtattr *__start = (struct rtattr *)skb_tail_pointer(skb); \ | ||
678 | RTA_PUT(skb, type, 0, NULL); \ | ||
679 | __start; }) | ||
680 | |||
681 | #define RTA_NEST_END(skb, start) \ | ||
682 | ({ (start)->rta_len = skb_tail_pointer(skb) - (unsigned char *)(start); \ | ||
683 | (skb)->len; }) | ||
684 | |||
685 | #define RTA_NEST_COMPAT(skb, type, attrlen, data) \ | ||
686 | ({ struct rtattr *__start = (struct rtattr *)skb_tail_pointer(skb); \ | ||
687 | RTA_PUT(skb, type, attrlen, data); \ | ||
688 | RTA_NEST(skb, type); \ | ||
689 | __start; }) | ||
690 | |||
691 | #define RTA_NEST_COMPAT_END(skb, start) \ | ||
692 | ({ struct rtattr *__nest = (void *)(start) + NLMSG_ALIGN((start)->rta_len); \ | ||
693 | (start)->rta_len = skb_tail_pointer(skb) - (unsigned char *)(start); \ | ||
694 | RTA_NEST_END(skb, __nest); \ | ||
695 | (skb)->len; }) | ||
696 | |||
697 | #define RTA_NEST_CANCEL(skb, start) \ | ||
698 | ({ if (start) \ | ||
699 | skb_trim(skb, (unsigned char *) (start) - (skb)->data); \ | ||
700 | -1; }) | ||
701 | |||
702 | #define RTA_GET_U8(rta) \ | ||
703 | ({ if (!rta || RTA_PAYLOAD(rta) < sizeof(u8)) \ | ||
704 | goto rtattr_failure; \ | ||
705 | *(u8 *) RTA_DATA(rta); }) | ||
706 | |||
707 | #define RTA_GET_U16(rta) \ | ||
708 | ({ if (!rta || RTA_PAYLOAD(rta) < sizeof(u16)) \ | ||
709 | goto rtattr_failure; \ | ||
710 | *(u16 *) RTA_DATA(rta); }) | ||
711 | |||
712 | #define RTA_GET_U32(rta) \ | ||
713 | ({ if (!rta || RTA_PAYLOAD(rta) < sizeof(u32)) \ | ||
714 | goto rtattr_failure; \ | ||
715 | *(u32 *) RTA_DATA(rta); }) | ||
716 | |||
717 | #define RTA_GET_U64(rta) \ | ||
718 | ({ u64 _tmp; \ | ||
719 | if (!rta || RTA_PAYLOAD(rta) < sizeof(u64)) \ | ||
720 | goto rtattr_failure; \ | ||
721 | memcpy(&_tmp, RTA_DATA(rta), sizeof(_tmp)); \ | ||
722 | _tmp; }) | ||
723 | |||
724 | #define RTA_GET_FLAG(rta) (!!(rta)) | ||
725 | |||
726 | #define RTA_GET_SECS(rta) ((unsigned long) RTA_GET_U64(rta) * HZ) | ||
727 | #define RTA_GET_MSECS(rta) (msecs_to_jiffies((unsigned long) RTA_GET_U64(rta))) | ||
728 | |||
729 | static inline struct rtattr * | ||
730 | __rta_reserve(struct sk_buff *skb, int attrtype, int attrlen) | ||
731 | { | ||
732 | struct rtattr *rta; | ||
733 | int size = RTA_LENGTH(attrlen); | ||
734 | |||
735 | rta = (struct rtattr*)skb_put(skb, RTA_ALIGN(size)); | ||
736 | rta->rta_type = attrtype; | ||
737 | rta->rta_len = size; | ||
738 | memset(RTA_DATA(rta) + attrlen, 0, RTA_ALIGN(size) - size); | ||
739 | return rta; | ||
740 | } | ||
741 | |||
742 | #define __RTA_PUT(skb, attrtype, attrlen) \ | ||
743 | ({ if (unlikely(skb_tailroom(skb) < (int)RTA_SPACE(attrlen))) \ | ||
744 | goto rtattr_failure; \ | ||
745 | __rta_reserve(skb, attrtype, attrlen); }) | ||
746 | |||
747 | extern void rtmsg_ifinfo(int type, struct net_device *dev, unsigned change); | 625 | extern void rtmsg_ifinfo(int type, struct net_device *dev, unsigned change); |
748 | 626 | ||
749 | /* RTNL is used as a global lock for all changes to network configuration */ | 627 | /* RTNL is used as a global lock for all changes to network configuration */ |
@@ -794,13 +672,6 @@ extern void __rtnl_unlock(void); | |||
794 | } \ | 672 | } \ |
795 | } while(0) | 673 | } while(0) |
796 | 674 | ||
797 | static inline u32 rtm_get_table(struct rtattr **rta, u8 table) | ||
798 | { | ||
799 | return RTA_GET_U32(rta[RTA_TABLE-1]); | ||
800 | rtattr_failure: | ||
801 | return table; | ||
802 | } | ||
803 | |||
804 | extern int ndo_dflt_fdb_dump(struct sk_buff *skb, | 675 | extern int ndo_dflt_fdb_dump(struct sk_buff *skb, |
805 | struct netlink_callback *cb, | 676 | struct netlink_callback *cb, |
806 | struct net_device *dev, | 677 | struct net_device *dev, |
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c index 21318d15bbc3..bc8a1cdaac98 100644 --- a/net/core/rtnetlink.c +++ b/net/core/rtnetlink.c | |||
@@ -541,19 +541,6 @@ static const int rta_max[RTM_NR_FAMILIES] = | |||
541 | [RTM_FAM(RTM_NEWACTION)] = TCAA_MAX, | 541 | [RTM_FAM(RTM_NEWACTION)] = TCAA_MAX, |
542 | }; | 542 | }; |
543 | 543 | ||
544 | void __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 | } | ||
555 | EXPORT_SYMBOL(__rta_fill); | ||
556 | |||
557 | int rtnetlink_send(struct sk_buff *skb, struct net *net, u32 pid, unsigned int group, int echo) | 544 | int rtnetlink_send(struct sk_buff *skb, struct net *net, u32 pid, unsigned int group, int echo) |
558 | { | 545 | { |
559 | struct sock *rtnl = net->rtnl; | 546 | struct sock *rtnl = net->rtnl; |
diff --git a/net/decnet/dn_fib.c b/net/decnet/dn_fib.c index 7eaf98799729..102d6106a942 100644 --- a/net/decnet/dn_fib.c +++ b/net/decnet/dn_fib.c | |||
@@ -505,6 +505,14 @@ static int dn_fib_check_attr(struct rtmsg *r, struct rtattr **rta) | |||
505 | return 0; | 505 | return 0; |
506 | } | 506 | } |
507 | 507 | ||
508 | static inline u32 rtm_get_table(struct rtattr **rta, u8 table) | ||
509 | { | ||
510 | if (rta[RTA_TABLE - 1]) | ||
511 | table = nla_get_u32((struct nlattr *) rta[RTA_TABLE - 1]); | ||
512 | |||
513 | return table; | ||
514 | } | ||
515 | |||
508 | static int dn_fib_rtm_delroute(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg) | 516 | static int dn_fib_rtm_delroute(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg) |
509 | { | 517 | { |
510 | struct net *net = sock_net(skb->sk); | 518 | struct net *net = sock_net(skb->sk); |