Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 66614
b: refs/heads/master
c: 14878f7
h: refs/heads/master
v: v3
  • Loading branch information
David L Stevens authored and David S. Miller committed Oct 10, 2007
1 parent fc3fd7a commit 802eb99
Show file tree
Hide file tree
Showing 12 changed files with 136 additions and 123 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 8b14a536701b50559a0d69d5d593323f550db4e9
refs/heads/master: 14878f75abd5bf1d38becb405801cd491ee215dc
27 changes: 2 additions & 25 deletions trunk/include/linux/snmp.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,35 +91,12 @@ enum
ICMP6_MIB_NUM = 0,
ICMP6_MIB_INMSGS, /* InMsgs */
ICMP6_MIB_INERRORS, /* InErrors */
ICMP6_MIB_INDESTUNREACHS, /* InDestUnreachs */
ICMP6_MIB_INPKTTOOBIGS, /* InPktTooBigs */
ICMP6_MIB_INTIMEEXCDS, /* InTimeExcds */
ICMP6_MIB_INPARMPROBLEMS, /* InParmProblems */
ICMP6_MIB_INECHOS, /* InEchos */
ICMP6_MIB_INECHOREPLIES, /* InEchoReplies */
ICMP6_MIB_INGROUPMEMBQUERIES, /* InGroupMembQueries */
ICMP6_MIB_INGROUPMEMBRESPONSES, /* InGroupMembResponses */
ICMP6_MIB_INGROUPMEMBREDUCTIONS, /* InGroupMembReductions */
ICMP6_MIB_INROUTERSOLICITS, /* InRouterSolicits */
ICMP6_MIB_INROUTERADVERTISEMENTS, /* InRouterAdvertisements */
ICMP6_MIB_INNEIGHBORSOLICITS, /* InNeighborSolicits */
ICMP6_MIB_INNEIGHBORADVERTISEMENTS, /* InNeighborAdvertisements */
ICMP6_MIB_INREDIRECTS, /* InRedirects */
ICMP6_MIB_OUTMSGS, /* OutMsgs */
ICMP6_MIB_OUTDESTUNREACHS, /* OutDestUnreachs */
ICMP6_MIB_OUTPKTTOOBIGS, /* OutPktTooBigs */
ICMP6_MIB_OUTTIMEEXCDS, /* OutTimeExcds */
ICMP6_MIB_OUTPARMPROBLEMS, /* OutParmProblems */
ICMP6_MIB_OUTECHOREPLIES, /* OutEchoReplies */
ICMP6_MIB_OUTROUTERSOLICITS, /* OutRouterSolicits */
ICMP6_MIB_OUTNEIGHBORSOLICITS, /* OutNeighborSolicits */
ICMP6_MIB_OUTNEIGHBORADVERTISEMENTS, /* OutNeighborAdvertisements */
ICMP6_MIB_OUTREDIRECTS, /* OutRedirects */
ICMP6_MIB_OUTGROUPMEMBRESPONSES, /* OutGroupMembResponses */
ICMP6_MIB_OUTGROUPMEMBREDUCTIONS, /* OutGroupMembReductions */
__ICMP6_MIB_MAX
};

#define __ICMP6MSG_MIB_MAX 512 /* Out+In for all 8-bit ICMPv6 types */

/* tcp mib definitions */
/*
* RFC 1213: MIB-II TCP group
Expand Down
1 change: 1 addition & 0 deletions trunk/include/net/if_inet6.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ struct ipv6_devstat {
struct proc_dir_entry *proc_dir_entry;
DEFINE_SNMP_STAT(struct ipstats_mib, ipv6);
DEFINE_SNMP_STAT(struct icmpv6_mib, icmpv6);
DEFINE_SNMP_STAT(struct icmpv6msg_mib, icmpv6msg);
};

struct inet6_dev
Expand Down
67 changes: 32 additions & 35 deletions trunk/include/net/ipv6.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,52 +112,49 @@ struct frag_hdr {
extern int sysctl_ipv6_bindv6only;
extern int sysctl_mld_max_msf;

/* MIBs */
DECLARE_SNMP_STAT(struct ipstats_mib, ipv6_statistics);
#define IP6_INC_STATS(idev,field) ({ \
#define _DEVINC(statname, modifier, idev, field) \
({ \
struct inet6_dev *_idev = (idev); \
if (likely(_idev != NULL)) \
SNMP_INC_STATS(_idev->stats.ipv6, field); \
SNMP_INC_STATS(ipv6_statistics, field); \
})
#define IP6_INC_STATS_BH(idev,field) ({ \
struct inet6_dev *_idev = (idev); \
if (likely(_idev != NULL)) \
SNMP_INC_STATS_BH(_idev->stats.ipv6, field); \
SNMP_INC_STATS_BH(ipv6_statistics, field); \
})
#define IP6_INC_STATS_USER(idev,field) ({ \
struct inet6_dev *_idev = (idev); \
if (likely(_idev != NULL)) \
SNMP_INC_STATS_USER(_idev->stats.ipv6, field); \
SNMP_INC_STATS_USER(ipv6_statistics, field); \
SNMP_INC_STATS##modifier((_idev)->stats.statname, (field)); \
SNMP_INC_STATS##modifier(statname##_statistics, (field)); \
})

/* MIBs */
DECLARE_SNMP_STAT(struct ipstats_mib, ipv6_statistics);

#define IP6_INC_STATS(idev,field) _DEVINC(ipv6, , idev, field)
#define IP6_INC_STATS_BH(idev,field) _DEVINC(ipv6, _BH, idev, field)
#define IP6_INC_STATS_USER(idev,field) _DEVINC(ipv6, _USER, idev, field)

DECLARE_SNMP_STAT(struct icmpv6_mib, icmpv6_statistics);
#define ICMP6_INC_STATS(idev, field) ({ \
struct inet6_dev *_idev = (idev); \
if (likely(_idev != NULL)) \
SNMP_INC_STATS(idev->stats.icmpv6, field); \
SNMP_INC_STATS(icmpv6_statistics, field); \
})
#define ICMP6_INC_STATS_BH(idev, field) ({ \
struct inet6_dev *_idev = (idev); \
if (likely(_idev != NULL)) \
SNMP_INC_STATS_BH((_idev)->stats.icmpv6, field); \
SNMP_INC_STATS_BH(icmpv6_statistics, field); \
})
#define ICMP6_INC_STATS_USER(idev, field) ({ \
struct inet6_dev *_idev = (idev); \
if (likely(_idev != NULL)) \
SNMP_INC_STATS_USER(_idev->stats.icmpv6, field); \
SNMP_INC_STATS_USER(icmpv6_statistics, field); \
})
DECLARE_SNMP_STAT(struct icmpv6msg_mib, icmpv6msg_statistics);

#define ICMP6_INC_STATS(idev, field) _DEVINC(icmpv6, , idev, field)
#define ICMP6_INC_STATS_BH(idev, field) _DEVINC(icmpv6, _BH, idev, field)
#define ICMP6_INC_STATS_USER(idev, field) _DEVINC(icmpv6, _USER, idev, field)

#define ICMP6_INC_STATS_OFFSET_BH(idev, field, offset) ({ \
struct inet6_dev *_idev = idev; \
__typeof__(offset) _offset = (offset); \
if (likely(_idev != NULL)) \
SNMP_INC_STATS_OFFSET_BH(_idev->stats.icmpv6, field, _offset); \
SNMP_INC_STATS_OFFSET_BH(icmpv6_statistics, field, _offset); \
})

#define ICMP6MSGOUT_INC_STATS(idev, field) \
_DEVINC(icmpv6msg, , idev, field +256)
#define ICMP6MSGOUT_INC_STATS_BH(idev, field) \
_DEVINC(icmpv6msg, _BH, idev, field +256)
#define ICMP6MSGOUT_INC_STATS_USER(idev, field) \
_DEVINC(icmpv6msg, _USER, idev, field +256)
#define ICMP6MSGIN_INC_STATS(idev, field) \
_DEVINC(icmpv6msg, , idev, field)
#define ICMP6MSGIN_INC_STATS_BH(idev, field) \
_DEVINC(icmpv6msg, _BH, idev, field)
#define ICMP6MSGIN_INC_STATS_USER(idev, field) \
_DEVINC(icmpv6msg, _USER, idev, field)

DECLARE_SNMP_STAT(struct udp_mib, udp_stats_in6);
DECLARE_SNMP_STAT(struct udp_mib, udplite_stats_in6);
#define UDP6_INC_STATS_BH(field, is_udplite) do { \
Expand Down
6 changes: 6 additions & 0 deletions trunk/include/net/snmp.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,12 @@ struct icmpv6_mib {
unsigned long mibs[ICMP6_MIB_MAX];
} __SNMP_MIB_ALIGN__;

#define ICMP6MSG_MIB_MAX __ICMP6MSG_MIB_MAX
struct icmpv6msg_mib {
unsigned long mibs[ICMP6MSG_MIB_MAX];
} __SNMP_MIB_ALIGN__;


/* TCP */
#define TCP_MIB_MAX __TCP_MIB_MAX
struct tcp_mib {
Expand Down
7 changes: 7 additions & 0 deletions trunk/net/ipv6/addrconf.c
Original file line number Diff line number Diff line change
Expand Up @@ -261,9 +261,15 @@ static int snmp6_alloc_dev(struct inet6_dev *idev)
sizeof(struct icmpv6_mib),
__alignof__(struct icmpv6_mib)) < 0)
goto err_icmp;
if (snmp_mib_init((void **)idev->stats.icmpv6msg,
sizeof(struct icmpv6msg_mib),
__alignof__(struct icmpv6msg_mib)) < 0)
goto err_icmpmsg;

return 0;

err_icmpmsg:
snmp_mib_free((void **)idev->stats.icmpv6);
err_icmp:
snmp_mib_free((void **)idev->stats.ipv6);
err_ip:
Expand All @@ -272,6 +278,7 @@ static int snmp6_alloc_dev(struct inet6_dev *idev)

static int snmp6_free_dev(struct inet6_dev *idev)
{
snmp_mib_free((void **)idev->stats.icmpv6msg);
snmp_mib_free((void **)idev->stats.icmpv6);
snmp_mib_free((void **)idev->stats.ipv6);
return 0;
Expand Down
5 changes: 5 additions & 0 deletions trunk/net/ipv6/af_inet6.c
Original file line number Diff line number Diff line change
Expand Up @@ -719,6 +719,9 @@ static int __init init_ipv6_mibs(void)
if (snmp_mib_init((void **)icmpv6_statistics, sizeof (struct icmpv6_mib),
__alignof__(struct icmpv6_mib)) < 0)
goto err_icmp_mib;
if (snmp_mib_init((void **)icmpv6msg_statistics,
sizeof (struct icmpv6msg_mib), __alignof__(struct icmpv6_mib)) < 0)
goto err_icmpmsg_mib;
if (snmp_mib_init((void **)udp_stats_in6, sizeof (struct udp_mib),
__alignof__(struct udp_mib)) < 0)
goto err_udp_mib;
Expand All @@ -730,6 +733,8 @@ static int __init init_ipv6_mibs(void)
err_udplite_mib:
snmp_mib_free((void **)udp_stats_in6);
err_udp_mib:
snmp_mib_free((void **)icmpv6msg_statistics);
err_icmpmsg_mib:
snmp_mib_free((void **)icmpv6_statistics);
err_icmp_mib:
snmp_mib_free((void **)ipv6_statistics);
Expand Down
12 changes: 3 additions & 9 deletions trunk/net/ipv6/icmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@

DEFINE_SNMP_STAT(struct icmpv6_mib, icmpv6_statistics) __read_mostly;
EXPORT_SYMBOL(icmpv6_statistics);
DEFINE_SNMP_STAT(struct icmpv6msg_mib, icmpv6msg_statistics) __read_mostly;
EXPORT_SYMBOL(icmpv6msg_statistics);

/*
* The ICMP socket(s). This is the most convenient way to flow control
Expand Down Expand Up @@ -456,8 +458,6 @@ void icmpv6_send(struct sk_buff *skb, int type, int code, __u32 info,
}
err = icmpv6_push_pending_frames(sk, &fl, &tmp_hdr, len + sizeof(struct icmp6hdr));

if (type >= ICMPV6_DEST_UNREACH && type <= ICMPV6_PARAMPROB)
ICMP6_INC_STATS_OFFSET_BH(idev, ICMP6_MIB_OUTDESTUNREACHS, type - ICMPV6_DEST_UNREACH);
ICMP6_INC_STATS_BH(idev, ICMP6_MIB_OUTMSGS);

out_put:
Expand Down Expand Up @@ -547,9 +547,6 @@ static void icmpv6_echo_reply(struct sk_buff *skb)
}
err = icmpv6_push_pending_frames(sk, &fl, &tmp_hdr, skb->len + sizeof(struct icmp6hdr));

ICMP6_INC_STATS_BH(idev, ICMP6_MIB_OUTECHOREPLIES);
ICMP6_INC_STATS_BH(idev, ICMP6_MIB_OUTMSGS);

out_put:
if (likely(idev != NULL))
in6_dev_put(idev);
Expand Down Expand Up @@ -656,10 +653,7 @@ static int icmpv6_rcv(struct sk_buff **pskb)

type = hdr->icmp6_type;

if (type >= ICMPV6_DEST_UNREACH && type <= ICMPV6_PARAMPROB)
ICMP6_INC_STATS_OFFSET_BH(idev, ICMP6_MIB_INDESTUNREACHS, type - ICMPV6_DEST_UNREACH);
else if (type >= ICMPV6_ECHO_REQUEST && type <= NDISC_REDIRECT)
ICMP6_INC_STATS_OFFSET_BH(idev, ICMP6_MIB_INECHOS, type - ICMPV6_ECHO_REQUEST);
ICMP6MSGIN_INC_STATS_BH(idev, type);

switch (type) {
case ICMPV6_ECHO_REQUEST:
Expand Down
7 changes: 7 additions & 0 deletions trunk/net/ipv6/ip6_output.c
Original file line number Diff line number Diff line change
Expand Up @@ -1399,6 +1399,13 @@ int ip6_push_pending_frames(struct sock *sk)

skb->dst = dst_clone(&rt->u.dst);
IP6_INC_STATS(rt->rt6i_idev, IPSTATS_MIB_OUTREQUESTS);
if (proto == IPPROTO_ICMPV6) {
struct inet6_dev *idev = ip6_dst_idev(skb->dst);

ICMP6MSGOUT_INC_STATS_BH(idev, icmp6_hdr(skb)->icmp6_type);
ICMP6_INC_STATS_BH(idev, ICMP6_MIB_OUTMSGS);
}

err = NF_HOOK(PF_INET6, NF_IP6_LOCAL_OUT, skb, NULL, skb->dst->dev, dst_output);
if (err) {
if (err > 0)
Expand Down
12 changes: 5 additions & 7 deletions trunk/net/ipv6/mcast.c
Original file line number Diff line number Diff line change
Expand Up @@ -1479,10 +1479,11 @@ static void mld_sendpack(struct sk_buff *skb)
err = NF_HOOK(PF_INET6, NF_IP6_LOCAL_OUT, skb, NULL, skb->dev,
mld_dev_queue_xmit);
if (!err) {
ICMP6_INC_STATS(idev,ICMP6_MIB_OUTMSGS);
IP6_INC_STATS(idev, IPSTATS_MIB_OUTMCASTPKTS);
ICMP6MSGOUT_INC_STATS_BH(idev, ICMPV6_MLD2_REPORT);
ICMP6_INC_STATS_BH(idev, ICMP6_MIB_OUTMSGS);
IP6_INC_STATS_BH(idev, IPSTATS_MIB_OUTMCASTPKTS);
} else
IP6_INC_STATS(idev, IPSTATS_MIB_OUTDISCARDS);
IP6_INC_STATS_BH(idev, IPSTATS_MIB_OUTDISCARDS);

if (likely(idev != NULL))
in6_dev_put(idev);
Expand Down Expand Up @@ -1822,10 +1823,7 @@ static void igmp6_send(struct in6_addr *addr, struct net_device *dev, int type)
err = NF_HOOK(PF_INET6, NF_IP6_LOCAL_OUT, skb, NULL, skb->dev,
mld_dev_queue_xmit);
if (!err) {
if (type == ICMPV6_MGM_REDUCTION)
ICMP6_INC_STATS(idev, ICMP6_MIB_OUTGROUPMEMBREDUCTIONS);
else
ICMP6_INC_STATS(idev, ICMP6_MIB_OUTGROUPMEMBRESPONSES);
ICMP6MSGOUT_INC_STATS(idev, type);
ICMP6_INC_STATS(idev, ICMP6_MIB_OUTMSGS);
IP6_INC_STATS(idev, IPSTATS_MIB_OUTMCASTPKTS);
} else
Expand Down
21 changes: 10 additions & 11 deletions trunk/net/ipv6/ndisc.c
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ static void __ndisc_send(struct net_device *dev,
struct neighbour *neigh,
struct in6_addr *daddr, struct in6_addr *saddr,
struct icmp6hdr *icmp6h, struct in6_addr *target,
int llinfo, int icmp6_mib_outnd)
int llinfo)
{
struct flowi fl;
struct dst_entry *dst;
Expand All @@ -441,9 +441,11 @@ static void __ndisc_send(struct net_device *dev,
struct inet6_dev *idev;
int len;
int err;
u8 *opt;
u8 *opt, type;

type = icmp6h->icmp6_type;

ndisc_flow_init(&fl, icmp6h->icmp6_type, saddr, daddr,
ndisc_flow_init(&fl, type, saddr, daddr,
dev->ifindex);

dst = ndisc_dst_alloc(dev, neigh, daddr, ip6_output);
Expand Down Expand Up @@ -504,7 +506,7 @@ static void __ndisc_send(struct net_device *dev,

err = NF_HOOK(PF_INET6, NF_IP6_LOCAL_OUT, skb, NULL, dst->dev, dst_output);
if (!err) {
ICMP6_INC_STATS(idev, icmp6_mib_outnd);
ICMP6MSGOUT_INC_STATS(idev, type);
ICMP6_INC_STATS(idev, ICMP6_MIB_OUTMSGS);
}

Expand Down Expand Up @@ -542,8 +544,7 @@ static void ndisc_send_na(struct net_device *dev, struct neighbour *neigh,

__ndisc_send(dev, neigh, daddr, src_addr,
&icmp6h, solicited_addr,
inc_opt ? ND_OPT_TARGET_LL_ADDR : 0,
ICMP6_MIB_OUTNEIGHBORADVERTISEMENTS);
inc_opt ? ND_OPT_TARGET_LL_ADDR : 0);
}

void ndisc_send_ns(struct net_device *dev, struct neighbour *neigh,
Expand All @@ -564,8 +565,7 @@ void ndisc_send_ns(struct net_device *dev, struct neighbour *neigh,

__ndisc_send(dev, neigh, daddr, saddr,
&icmp6h, solicit,
!ipv6_addr_any(saddr) ? ND_OPT_SOURCE_LL_ADDR : 0,
ICMP6_MIB_OUTNEIGHBORSOLICITS);
!ipv6_addr_any(saddr) ? ND_OPT_SOURCE_LL_ADDR : 0);
}

void ndisc_send_rs(struct net_device *dev, struct in6_addr *saddr,
Expand Down Expand Up @@ -599,8 +599,7 @@ void ndisc_send_rs(struct net_device *dev, struct in6_addr *saddr,
#endif
__ndisc_send(dev, NULL, daddr, saddr,
&icmp6h, NULL,
send_sllao ? ND_OPT_SOURCE_LL_ADDR : 0,
ICMP6_MIB_OUTROUTERSOLICITS);
send_sllao ? ND_OPT_SOURCE_LL_ADDR : 0);
}


Expand Down Expand Up @@ -1455,7 +1454,7 @@ void ndisc_send_redirect(struct sk_buff *skb, struct neighbour *neigh,
IP6_INC_STATS(idev, IPSTATS_MIB_OUTREQUESTS);
err = NF_HOOK(PF_INET6, NF_IP6_LOCAL_OUT, buff, NULL, dst->dev, dst_output);
if (!err) {
ICMP6_INC_STATS(idev, ICMP6_MIB_OUTREDIRECTS);
ICMP6MSGOUT_INC_STATS(idev, NDISC_REDIRECT);
ICMP6_INC_STATS(idev, ICMP6_MIB_OUTMSGS);
}

Expand Down
Loading

0 comments on commit 802eb99

Please sign in to comment.