- 论坛徽章:
- 6
|
回复 1# jonas_mao
请问上面if (inet_addr_type(dev_net(skb_dst(skb)->dev), addr) != RTN_LOCAL)
一行中 if 判断的地址类型为什么是LOCAL的,这里的local是不是指本地存在的地址,ip 选项的时间戳的IPOPT_TS_PRESPEC这种不是说记录的ip地址如果是本地设备节点的地址的话才记录时间的,这里为毛是 != RTN_LOCAL ? 不可能是个坑吧>
1. 这的确是个坑
2. 这是个很老的坑,2011年3月份已经填上了
详细信息:
git log 8628bd8a- commit 8628bd8af7c4c14f40f5183f80f5744c4e682439
- Author: Jan Luebbe <jluebbe@debian.org>
- Date: Thu Mar 24 07:44:22 2011 +0000
- ipv4: Fix IP timestamp option (IPOPT_TS_PRESPEC) handling in ip_options_echo()
-
- The current handling of echoed IP timestamp options with prespecified
- addresses is rather broken since the 2.2.x kernels. As far as i understand
- it, it should behave like when originating packets.
-
- Currently it will only timestamp the next free slot if:
- - there is space for *two* timestamps
- - some random data from the echoed packet taken as an IP is *not* a local IP
-
- This first is caused by an off-by-one error. 'soffset' points to the next
- free slot and so we only need to have 'soffset + 7 <= optlen'.
-
- The second bug is using sptr as the start of the option, when it really is
- set to 'skb_network_header(skb)'. I just use dptr instead which points to
- the timestamp option.
-
- Finally it would only timestamp for non-local IPs, which we shouldn't do.
- So instead we exclude all unicast destinations, similar to what we do in
- ip_options_compile().
-
- Signed-off-by: Jan Luebbe <jluebbe@debian.org>
- Signed-off-by: David S. Miller <davem@davemloft.net>
- diff --git a/net/ipv4/ip_options.c b/net/ipv4/ip_options.c
- index 1906fa3..28a736f 100644
- --- a/net/ipv4/ip_options.c
- +++ b/net/ipv4/ip_options.c
- @@ -140,11 +140,11 @@ int ip_options_echo(struct ip_options * dopt, struct sk_buff * skb)
- } else {
- dopt->ts_needtime = 0;
-
- - if (soffset + 8 <= optlen) {
- + if (soffset + 7 <= optlen) {
- __be32 addr;
-
- - memcpy(&addr, sptr+soffset-1, 4);
- - if (inet_addr_type(dev_net(skb_dst(skb)->dev), addr) != RTN_LOCAL) {
- + memcpy(&addr, dptr+soffset-1, 4);
- + if (inet_addr_type(dev_net(skb_dst(skb)->dev), addr) != RTN_UNICAST) {
- dopt->ts_needtime = 1;
复制代码 |
|