diff options
Diffstat (limited to 'include/linux/rtnetlink.h')
-rw-r--r-- | include/linux/rtnetlink.h | 132 |
1 files changed, 1 insertions, 131 deletions
diff --git a/include/linux/rtnetlink.h b/include/linux/rtnetlink.h index 2c1de8982c85..db71c4ad8624 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, |
@@ -625,124 +619,7 @@ extern void rtnl_notify(struct sk_buff *skb, struct net *net, u32 pid, | |||
625 | extern void rtnl_set_sk_err(struct net *net, u32 group, int error); | 619 | extern void rtnl_set_sk_err(struct net *net, u32 group, int error); |
626 | extern int rtnetlink_put_metrics(struct sk_buff *skb, u32 *metrics); | 620 | extern int rtnetlink_put_metrics(struct sk_buff *skb, u32 *metrics); |
627 | extern int rtnl_put_cacheinfo(struct sk_buff *skb, struct dst_entry *dst, | 621 | 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, long expires, u32 error); |
629 | u32 error); | ||
630 | |||
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 | 623 | ||
747 | extern void rtmsg_ifinfo(int type, struct net_device *dev, unsigned change); | 624 | extern void rtmsg_ifinfo(int type, struct net_device *dev, unsigned change); |
748 | 625 | ||
@@ -794,13 +671,6 @@ extern void __rtnl_unlock(void); | |||
794 | } \ | 671 | } \ |
795 | } while(0) | 672 | } while(0) |
796 | 673 | ||
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, | 674 | extern int ndo_dflt_fdb_dump(struct sk_buff *skb, |
805 | struct netlink_callback *cb, | 675 | struct netlink_callback *cb, |
806 | struct net_device *dev, | 676 | struct net_device *dev, |