Get or Delete Xfrm Policy

##summary
xfrm_get_policy first locate the xfrm policy by policy index(from user space) or policy selector.

  1. if get_policy, alloc a new skb, and encapsulate the xfrm policy to it, then sent it.
  2. if delete policy, call xfrm_audit_policy_delete to delete the plolicy, and call km_policy_notify to notify.

xfrm policy del/get 使用的是同一个函数 xfrm_get_policy.

Read More

Add a Ip Address on a Interface(todo)

##summary
When a ip addr is added, two unicat route entries are added to route table.

  1. a host route entry is added to local table.
    The packet to local host will be routed by this route entry. The route still is valid, even the related interface is shut down.
  2. a connected route is added to main table.
    It is used to forward the packet to the hosts in the same sub network, it will disappear when interface down
  3. two broad cast routes entry also added.

Read More

通过git reflog 找回的commit

Prepare

1
2
3
4
[martin@fc17 git_study]$ git log --oneline 
83e7d89 add lineb in readme <== this commit will be reset hardly
4fd6367 add line1 in readme
bfd590e touch readme
1
2
3
4
5
[martin@fc17 git_study]$ git reset HEAD^ --hard 
HEAD is now at 4fd6367 add line1 in readme
[martin@fc17 git_study]$ git log --oneline
4fd6367 add line1 in readme
bfd590e touch readme
1
2
3
[martin@fc17 git_study]$  cat readme 
line a
通过git reflog 我们可以得到误删除的commit对应的ID

git reflog

1
2
3
4
5
[martin@fc17 git_study]$ git reflog 
4fd6367 HEAD@{0}: reset: moving to HEAD^
83e7d89 HEAD@{1}: commit: add lineb in readme
4fd6367 HEAD@{2}: commit: add line1 in readme
bfd590e HEAD@{3}: commit (initial): touch readme

有了commit ID, 一切就OK了。想干啥都行了 cherry-pick, checkout …

1
2
3
4
5
6
7
8
9
[martin@fc17 git_study]$ git checkout -b try_recover 83e7d89 
Switched to a new branch ‘try_recover’
[martin@fc17 git_study]$ git log —oneline
83e7d89 add lineb in readme
4fd6367 add line1 in readme
bfd590e touch readm
[martin@fc17 git_study]$ cat readme
line a
line b

Get netdevice stat

##call trace

the ‘.show’ method in device_attribute will call the netstat_show,
some of the driver read the part of stat from NIC register,
but most count the stat by software in dev->stat

1
2
3
4
5
> dev_get_stats
> > dev_get_stats
> > > ops = dev->netdev_ops;
> > > > ops->ndo_get_stats64
> > > > > ixgbe_get_stats64,

Read More

git study summary

##create repo

1
2
3
4
5
6
7
8
9
10
11
12
13
1087 git init —bare study.git <=== crate study.git 
1088 ls study.git/ 1089 cat study.git/config
1090 ls 1091 git clone study.git/
1092 ls
1093 cd study
1094 ls
1095 touch study.readme
1096 echo “This is readme for study(master)”
1097 echo “This is readme for study(master)” >>study.readme
1098 git add study.readme
1099 git commit -s study.readme <===== commit a file for test.
1100 git push origin master <===== push them to the server(locally).
1101 cd .. 1102 ls

##create a remote branch.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
1103 git clone study.git/ tmp1 
1104 cd tmp1/
1105 ls
1106 git log
1107 cd ..
1108 ls
1109 cd study
1110 ls
1111 git checkout -b dev_junwei <======== create a locally branch.
1112 ls
1113 vim study.readme
1114 ls
1115 git commit study.readme
1116 git mv study.readme study.dev.junwei.readme
1117 git push origin dev_junwei <======== create a remote branch. and remote branch has same name with the local one.
1118 git branch

##create a mirror for the study.git

1
git clone —bare study.git/ mirror.git

##Add a new remote git resp.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
1134  git remote add mirror /home/junwei/git_study/mirror.git/  <=== add a new remote and name it as mirror.
1136 git remote show
1137 git remote show origin
1138 git remote show mirror
1139 git status
1140 git fetch mirror <===== !!!! important, Only thus following checkout could be sucess

1141 git checkout -b m_master mirror/master <=== create local branch according remote branch.
1142 git checkout -b m_dev mirror/dev_junwei

1164 git commit -sa <=== commit a change to local branch.

1168 git push mirror m_dev:dev_junwei <=== push the local change to remote branch. "m_dev" is created in 1142.

1174 git push mirror m_dev:dev_junwei <=== do some change/commit and push again to remote mirror.
FU CK( NOT m_dev/dev_junwei)!!!!!!!

1176 git status

git config push.default tracking 来让git push命令默认push当前的分支到对应的remote tracking分支上

1
2
3
4
5
6
7
8
[junwei@junwei study]$ git config push.default tracking
[junwei@junwei study]$ cat .git/config
....
[push]
default = tracking
[junwei@junwei study]$

git push origin :remote_branch_name
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
[martin@fc16 example]$ git log --oneline  
7f9df38 This file should only be seen on branch 'dev'.
5679bd2 fill a line in readme file on branch 'dev'.
3d83de1 Add an empty readme
[martin@fc16 example]$
[martin@fc16 example]$ git tag init 3d83de1
[martin@fc16 example]$ git tag v1.0
[martin@fc16 example]$
[martin@fc16 example]$ git tag
init
v1.0
[martin@fc16 example]$ git push
Everything up-to-date
[martin@fc16 example]$ git push --tags
Total 0 (delta 0), reused 0 (delta 0)
To /var/lib/git/test/example.git/
* [new tag] init -> init
* [new tag] v1.0 -> v1.0
[martin@fc16 example]$

##delete remote tags.

1
2
3
4
[martin@fc16 example]$ git push  origin  :v1.a0
To /var/lib/git/test/example.git/
- [deleted] v1.a0
[martin@fc16 example]$