2008年6月6日 星期五

荒漠甘泉06062008

「你們要....儆醒禱告。」(聖經彼得前書四章 7 節)

  朋友,不要冒險和世界接觸,如果你還沒有禱告。當你晚上跪下禱告的時候,瞌睡前來壓在你眼瞼上;一天辛苦的工作成了你的託辭,你就縮短你的禱告,從神面前退去休息了。到了早晨,因為起身遲了,一天的工作已經堆在你面前,你又向神通融一下,匆匆促促把晨間最寶貴的交通草率了事。

  你一點都不儆醒禱告!你忽略了儆醒;這樣的忽略能不能補救的呢?不能!

  你不儆醒禱告,是一件何等嚴重的事!試探在你面前,你無法對付。仇敵在前引誘,你無法站住。 四周的壓迫你無法忍耐。和神的交通你無法維持。和同作肢體的生了隔膜,在不信的人前失了見證。 屬靈的能力消失,愛主的心冷淡。做事憑自己的喜好,不憑神的旨意。你會覺得你和神離得非常遙遠。 不禱告一天,等於墮落一天。── 勞勃生(Frederick W. Robertson

  信徒們,不要作無謂的冒險,把儆醒禱告這件事忽略了。神的獨生子耶穌基督尚且需要天未亮即起身禱告,把祂心中的事向神傾倒出來,何況我們呢?

  無禱告的生命,是無能力的生命。──

2008年6月5日 星期四

又被買走了...

公司又被買走了... 好吧, 數數看工作以來的公司...

第一間公司, 2001 年七月加入, 2002 年十月合併另一間公司, 2004 年一月被併購. 一直待待待, 待到 2006 年九月離開; 2006 年九月離開之後到了另一間公司, 待到 2008 年一月; 二月換到現在公司, 結果今天宣佈要被併購...

嗯嗯嗯... 好吧, 只好再看看囉...

2008年6月3日 星期二

sk_buff->cb

閑來無事, 把 Understanding Linux Network Internals 抓來看看, 剛好看到了
sk_buff 這個恐怖的 structure. 其中有個 sk_buff->cb[64] 這個 64 bytes 的
東西, 專門拿來把一些 control information 放進去裡面的, 各層 protocol 都
可以拿來用, 但要小心別互相給蓋掉了...

看一下 definition:

include/linux/skbuff.h:

struct sk_buff {
/* These two members must be first. */
struct sk_buff *next;
struct sk_buff *prev;
:
:
/*
* This is the control buffer. It is free to use for every
* layer. Please put your private variables there. If you
* want to keep them across layers you have to do a skb_clone()
* first. This is owned by whoever has the skb queued ATM.
*/
char cb[64];
:
:
}

再來看一下 TCP layer 裡面有用到的部份...

include/net/tcp.h:

/* This is what the send packet queuing engine uses to pass
* TCP per-packet control information to the transmission
* code. We also store the host-order sequence numbers in
* here too. This is 36 bytes on 32-bit architectures,
* 40 bytes on 64-bit machines, if this grows please adjust
* skbuff.h:skbuff->cb[xxx] size appropriately.
*/
struct tcp_skb_cb {
union {
struct inet_skb_parm h4;
#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
struct inet6_skb_parm h6;
#endif
} header; /* For incoming frames */
__u32 seq; /* Starting sequence number */
__u32 end_seq; /* SEQ + FIN + SYN + datalen */
__u32 when; /* used to compute rtt's */
__u8 flags; /* TCP header flags. */

/* NOTE: These must match up to the flags byte in a
* real TCP header.
*/
:
:
__u8 sacked; /* State flags for SACK/FACK. */
:
:

__u16 urg_ptr; /* Valid w/URG flags is set. */
__u32 ack_seq; /* Sequence number ACK'd */
};

#define TCP_SKB_CB(__skb) ((struct tcp_skb_cb *)&((__skb)->cb[0]))

struct inet_skb_parm 是啥鬼捏?

include/net/ip.h:

struct inet_skb_parm
{
struct ip_options opt; /* Compiled IP options
unsigned char flags;
:
:
};

哇靠, 又來一個 struct ip_options...

include/linux/ip.h:

struct ip_options {
__u32 faddr; /* Saved first hop address */
unsigned char optlen;
unsigned char srr;
unsigned char rr;
unsigned char ts;
unsigned char is_setbyuser:1, /* Set by setsockopt?
is_data:1, /* Options in __data, rather th
is_strictroute:1, /* Strict source route
srr_is_hit:1, /* Packet destination addr was
is_changed:1, /* IP checksum more not valid
rr_needaddr:1, /* Need to record addr of outgo
ts_needtime:1, /* Need to record timestamp
ts_needaddr:1; /* Need to record addr of outgo
unsigned char router_alert;
unsigned char __pad1;
unsigned char __pad2;
unsigned char __data[0];
};

Total 大約會用到 36 bytes (32bit machine), or 40 bytes (64bit machine)...

事實上在 protocol layer 裡還有其他幾個地方會用到 skb->cb 的咚咚:

[MVL4 include/net]$ grep "cb\[" *
ipx.h:#define IPX_SKB_CB(__skb) ((struct ipx_cb *)&((__skb)->cb[0]))
llc_conn.h: skb->cb[sizeof(skb->cb) - 1] = type;
llc_conn.h: return skb->cb[sizeof(skb->cb) - 1];
tcp.h: * skbuff.h:skbuff->cb[xxx] size appropriately.
tcp.h:#define TCP_SKB_CB(__skb) ((struct tcp_skb_cb *)&((__skb)->cb[0]))


[MVL4 include/linux]$ grep "cb\[" *
if_vlan.h:#define VLAN_TX_SKB_CB(__skb) ((struct vlan_skb_tx_cookie *)&((__skb)->cb[0]))
if_vlan.h: * Puts the VLAN tag in @skb->cb[] and lets the device do the rest
if_vlan.h: * __vlan_hwaccel_get_tag - get the VLAN ID that is in @skb->cb[]
if_vlan.h: * Returns error if @skb->cb[] is not set correctly
llc.h:#define llc_ui_skb_cb(__skb) ((struct sockaddr_llc *)&((__skb)->cb[0]))

所以盡量要使用 skb->cb[] 內容的話, 把它給擺在 cb[36] 以後吧, 反正有 64 bytes 可用...

... 這也難怪了... 先前把東西擺在 cb[0] & cb[1], 老是會不見 @_@ 唉啊, 真是沒看清楚啊~~~

likely & unlikely part II

剛剛在 Understanding Linux Network Internals 上看到的, 節錄出來一下以免以後忘了... :p


1.2.9. Compile-Time Optimization for Condition Checks

Most of the time, when the kernel compares a variable against some external value to see whether a given condition is met, the result is extremely likely to be predictable. This is pretty common, for example, with code that enforces sanity checks. The kernel uses the likely and unlikely macros, respectively, to wrap comparisons that are likely to return a true (1) or false (0) result. Those macros take advantage of a feature of the gcc compiler that can optimize the compilation of the code based on that information.

Here is an example. Let's suppose you need to call the do_something function, and that in case of failure, you must handle it with the handle_error function:

err = do_something(x,y,z);
if (err)
handle_error(err);

Under the assumption that do_something rarely fails, you can rewrite the code as follows:

err = do_something(x,y,z);
if (unlikely(err))
handle_error(err);

An example of the optimization made possible by the likely and unlikely macros is in handling options in the IP header. The use of IP options is limited to very specific cases, and the kernel can safely assume that most IP packets do not carry IP options. When the kernel forwards an IP packet, it needs to take care of options according to the rules described in Chapter 18. The last stage of forwarding an IP packet is taken care of by ip_forward_finish. This function uses the unlikely macro to wrap the condition that checks whether there is any IP option to take care of. See the section "ip_forward_finish Function" in Chapter 20.


基本上跟先前的認知是一樣的, 但發覺 ARM, MIPS 跟 PowerPC 用的 GNU crosscompiler 似乎都不會去做這些個 optimization... x86 的就會...

2008年5月30日 星期五

荒漠甘泉 05302008

「除了從地上買來的那十四萬四千人以外,沒有人能學這歌。」(聖經啟示錄十四章 3 節)

  有一種歌,既非藝術所能教,也非樂理所能編,只有在患難中能學會的。這種歌是憑記憶的,憑經驗的。

  沒有一個天使能唱得像我們這麼好聽。他們要唱,他們就必須走我們所走的道路,經歷我們所經歷的經歷。沒有一人能學會,除了十架之子。

  所以,我的己哪!你現在正在從父學習音樂功課。祂訓練你,要使你有資格加入天上的大歌詠團。有一部分聲音,沒有別人能擔任,連天使和天使長也不能,只有你一人能擔任的。天使雖能唱高音,但是這幽而沉的低音,只有你一人能唱。

  你的父在訓練你擔任那天使所不能擔任的一部分;訓練你的學校就是苦難。

  在黑雲中祂試你的聲音,在憂傷中祂教你唱歌的表情,在患難中祂練你的氣,在試煉中祂教你發音的準確。

  不要輕看這神的音樂院;許多人雖然羨慕,可是還不能被選呢!── 馬得勝(George Matheson

荒漠甘泉 05292008

「我乃稱你們為朋友。」(聖經約翰福音十五章 15 節)

  數年前某大學有一位年老的德文教授,他的生活是為全校學生所欽佩的。他們中間有幾個好奇的學生,很想探聽他所以這樣生活的祕訣;所以其中有一個學生隱匿在教授的書室中,看他每天晚上在那裡幹些什麼。

  教授走進書室,時間已很遲了。看他的樣子似乎很累,但是他坐下來,打開聖經,很虔誠的讀了一個鐘頭。然後低頭默禱;最後,把聖經關起來,說:「主耶穌,我們又是一次歡聚!」

  與主歡聚是屬靈生活中的最高點;每一個基督人,該不惜任何代價,尋求與主「又是一次歡聚」。

  禱告和讀經能使我們覺得基督的實在,越在密室中追求主的同在的,越覺得主的實在。── 貝伯考克(Maltbie D. Babcock

2008年5月16日 星期五

恐怖的天災...

這幾天新聞都是天災的消息 - 緬甸的水災, 四川的地震.

不曉得是不是這兩個國家做了太多的壞事, 神一手降下災難, 想好好逞罰他們?? 昨天打開 Tivo 看 Discovery 的"聖經解碼"其中一段講到耶利哥城, 索多瑪, 跟蛾摩拉, 現代考古隊在死海東南角有發現被火燒過的大城市, 據大家的考證有可能就是索多瑪跟蛾摩拉...

會不會四川就像是這兩個城市一樣, 被神給懲罰的地方? ... 像幾年前的集集一樣??

不過看到新聞一則一則的報出來, 感覺實在是很難過...

昨晚十一點多跟阿布去散步, 天空畫出一長條的流星線, 嚇死我了!! 好大一顆流星!! 從東南一路劃到西南角去, 看起來真是叫人覺得不舒服...

希望不會還有啥天災發生...