2012年4月28日 星期六

在 Linux 下使用 IPv6

環境:Debian 6.0

未設定之前應該連不上:Google IPv6 首頁
IPv6 Forum Taiwan 左邊也會顯示您使用 IPv4 連線。

1.中研院 IPv6 Tunnel Broker 申請帳號
申請完後,會收到一封類似這樣的 mail
User account information to be used on the Migration Broker:User id: XXXXXXXPassword: YYYYYYYEmail address: XXXXXXXX@gmail.com
Use these values with TSP client to get IPv6 connectivity.
<To cut and paste to tspc.conf>#userid=XXXXXXX
passwd=YYYYYYY
#<End cut and paste>
2.接著下載安裝 TSPC (Tunnel Setup Protocol Client)
$ tar zxvf tspc-2.1.1-src.tgz
$ cd tspc2
$ make all target=linux
$ sudo make install target=linux installdir=/opt/tsp

3. 設定 TSPC
$ sudo vi /opt/tsp/bin/tspc.conf
將裡面的 userid 和 passwd 改成你申請的,另外 server 也要改:
server=tb2.ipv6.ascc.net

4.執行 TSPC
$ sudo /opt/tsp/bin/tspc -vvv -f /opt/tsp/bin/tspc.conf
連線成功會自動送到背景 daemon,用 ifconfig 可以看到新增了一個 tun
tun       Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
          inet6 addr: (your IPv6 address)/128 Scope:Global
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1280  Metric:1
          RX packets:303 errors:0 dropped:0 overruns:0 frame:0
          TX packets:332 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:500
          RX bytes:166407 (162.5 KiB)  TX bytes:71068 (69.4 KiB)
檢查 IPv6 routing table 可以用 route -6,不過個人偏好 ip -f inet6 route
(your IPv6 address) dev tun  proto kernel  metric 256  mtu 1280 rtt 0.00ms rttvar 0.00ms cwnd 102000::/3 dev tun  metric 1 fe80::/64 dev wlan0  proto kernel  metric 256 fe80::/64 dev tun  proto kernel  metric 256 default dev tun  metric 1 
再打開一開始說的兩個網頁,應該就會有所不同!

git 筆記

git add, rm, commit, clone, fetch, reset, checkout 比較基本,應該不用記。
目前使用的 git 版本是 1.7.9,不一定每個版本都一樣!


checkout 某個 commit 出來 build
> git archive --format=tar --remote=repository_location commit_id | tar xvf -

不用 commit 拿 commit ID
把改過的檔案先放到 stage
> git add files
建立 tree object 就會出現 commit ID 啦
> git write-tree

從其他 branch 抓 commit 進來
> git cherry-pick commit_id
其實也蠻常用 branch~加數字:0 是 HEAD, 1 是 HEAD^ 以此類推
> git cherry-pick some_branch_name~0


比較兩個 tree
> git diff-tree -p branch1 branch2


看某一檔案每一行的 commit 紀錄
> git blame somefile.c


merge branch1 到 branch2
> git merge branch1 branch2


送 patch 到 mailing list
產生 commitA 到 commitB 的 patch 檔和 cover letter
> git format-patch --cover-letter -n commitA..commitB
寄 patch 出去
> git send-email --smtp-server yourserver --from whoareyou@mail.server.com --to mailing@list


從 mbox apply patch
> git am -3 -i -s -u patch.mbox
-3 是嘗試用 3-way merge
-i 是 interactively
-s 跟平常一樣是 signoff
-u 是 utf8


調整 commit 順序等
> git rebase -i commit_id
會跳出 editor 讓你調整 commit,例如:


pick e29ad97 Blackfin: cache result of cpp check
pick 042f9f1 gpio: Adapt PCA9698 to standard GPIO API
pick bd25fdb Makefile: Add the missing dependency for spl target


並提示:

# Commands:
#  p, pick = use commit
#  r, reword = use commit, but edit the commit message
#  e, edit = use commit, but stop for amending
#  s, squash = use commit, but meld into previous commit
#  f, fixup = like "squash", but discard this commit's log message
#  x, exec = run command (the rest of the line) using shell
把上面的 pick 換成你想要做的事情,當然也可以調整 pick 順序,例如:


r 042f9f1 gpio: Adapt PCA9698 to standard GPIO API

e e29ad97 Blackfin: cache result of cpp check
pick bd25fdb Makefile: Add the missing dependency for spl target
存檔離開之後,git 會從上而下 pick 進原本的 branch。
其實上面作用跟 checkout 出一個 branch 到 042f9f1~1,然後再一個一個 cherry-pick 進來差不多。




我最常用的就是 fixup... 因為常常打錯字或者放到空白orz

2012年4月22日 星期日

我要開始寫網誌了!

年紀大了,記性不好,該作點筆記。

會寫些 kernel、embedded system、networking 的文章。